### Question:
AndroidNfcReader extends AbstractSelectionLocalReader implements NfcAdapter.ReaderCallback { @Override protected void openPhysicalChannel() throws KeypleChannelStateException { if (!checkSePresence()) { try { LOG.debug("Connect to tag.."); tagProxy.connect(); LOG.info("Tag connected successfully : " + printTagId()); } catch (IOException e) { LOG.error("Error while connecting to Tag "); e.printStackTrace(); throw new KeypleChannelStateException("Error while opening physical channel", e); } } else { LOG.info("Tag is already connected to : " + printTagId()); } } AndroidNfcReader(); Map<String, String> getParameters(); @Override void setParameter(String key, String value); @Override TransmissionMode getTransmissionMode(); @Override void onTagDiscovered(Tag tag); String printTagId(); static final String FLAG_READER_SKIP_NDEF_CHECK; static final String FLAG_READER_NO_PLATFORM_SOUNDS; static final String FLAG_READER_PRESENCE_CHECK_DELAY; }### Answer:
@Test public void openPhysicalChannelSuccess() throws KeypleReaderException { insertSe(); when(tagProxy.isConnected()).thenReturn(false); reader.openPhysicalChannel(); }
@Test(expected = KeypleReaderException.class) public void openPhysicalChannelError() throws KeypleBaseException, IOException { insertSe(); when(tagProxy.isConnected()).thenReturn(false); doThrow(new IOException()).when(tagProxy).connect(); reader.openPhysicalChannel(); }