GetEidLpadWorker implements LpadWorker<LpadWorkerExchange<String>, String> { public String run(final LpadWorkerExchange<String> lpadWorkerExchange) { progress.setTotalSteps(3); progress.stepExecuted(ProgressStep.GET_EID_RETRIEVING, "getEID retrieving..."); inputValidation(lpadWorkerExchange == null, "Lpa dWorker Exchange must be provided"); inputValidation(StringUtils.isBlank(lpadWorkerExchange.getBody()), "EID APDU must be provided"); logDebug("EID APDU: " + lpadWorkerExchange); String eidapduResponseStr = apduChannel.transmitAPDU(lpadWorkerExchange.getBody()); logDebug("Response: " + eidapduResponseStr); return convertGetEuiccData(eidapduResponseStr, progress); } GetEidLpadWorker(final Progress progress,
                            final ApduChannel apduChannel); String run(final LpadWorkerExchange<String> lpadWorkerExchange);  }
@Test(expected = IllegalArgumentException.class) public void shouldThrowIllegalArgumentExceptionWhenTransmitAPDUReturnNull() { when(mockApduChannel.transmitAPDU(any(String.class))) .thenReturn(null); getIdWorker.run(buildStringLpadWorkerExchange(ApduUtils.getEIDApdu())); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowIllegalArgumentExceptionWhenTransmitAPDUReturnEmpty() { when(mockApduChannel.transmitAPDU(any(String.class))) .thenReturn(""); getIdWorker.run(buildStringLpadWorkerExchange(ApduUtils.getEIDApdu())); }
@Test(expected = RuntimeException.class) public void shouldThrowRuntimeExceptionWhenIdentifierDoesNotMatch() { when(mockApduChannel.transmitAPDU(any(String.class))) .thenReturn("A0A40000027F"); getIdWorker.run(buildStringLpadWorkerExchange(ApduUtils.getEIDApdu())); }
@Test(expected = RuntimeException.class) public void shouldThrowRuntimeExceptionWhenDecodeFails() { LogStub.getInstance().setLogLevel(Level.FINEST); when(mockApduChannel.transmitAPDU(any(String.class))) .thenReturn("asdasdasd"); getIdWorker.run(buildStringLpadWorkerExchange(ApduUtils.getEIDApdu())); }
@Test(expected = RuntimeException.class) public void shouldThrowRuntimeExceptionWhenEidApduIsNull() { getIdWorker.run(buildStringLpadWorkerExchange(null)); }
@Test(expected = RuntimeException.class) public void shouldThrowRuntimeExceptionWhenEidApduIsEmpty() { getIdWorker.run(buildStringLpadWorkerExchange("")); }
@Test public void shouldGetEidData() { when(mockApduChannel.transmitAPDU(any(String.class))) .thenReturn("bf3e125a10890440500010006800000000000001709000"); String eidData = getIdWorker.run(buildStringLpadWorkerExchange(ApduUtils.getEIDApdu())); assertEquals("89044050001000680000000000000170", eidData); verify(mockProgress, times(1)) .setTotalSteps(3); verify(mockProgress, times(1)) .stepExecuted(ProgressStep.GET_EID_RETRIEVING, "getEID retrieving..."); verify(mockProgress, times(1)) .stepExecuted(ProgressStep.GET_EID_CONVERTING, "getEID converting..."); verify(mockProgress, times(1)) .stepExecuted(ProgressStep.GET_EID_CONVERTED, "getEID converted..."); }