VerifyPinRespPars extends AbstractPoResponseParser { public int getRemainingAttemptCounter() { int attemptCounter; switch (response.getStatusCode()) { case 0x6983: attemptCounter = 0; break; case 0x63C1: attemptCounter = 1; break; case 0x63C2: attemptCounter = 2; break; case 0x9000: attemptCounter = 3; break; default: throw new IllegalStateException( "Incorrect status word: " + String.format("0x%04X", response.getStatusCode())); } return attemptCounter; } VerifyPinRespPars(ApduResponse response, VerifyPinCmdBuild builder); int getRemainingAttemptCounter();  }
@Test public void verifyPinRespPars_goodStatus() { VerifyPinRespPars parser = new VerifyPinRespPars(new ApduResponse(SW1SW2_OK, null), null); parser.checkStatus(); assertThat(parser.getRemainingAttemptCounter()).isEqualTo(3); }
@Test(expected = IllegalStateException.class) public void verifyPinRespPars_badStatus_2() { VerifyPinRespPars parser = new VerifyPinRespPars(new ApduResponse(SW1SW2_KO, null), null); parser.getRemainingAttemptCounter(); shouldHaveThrown(IllegalStateException.class); }
@Test(expected = CalypsoPoPinException.class) public void verifyPinRespPars_attempts_1() { VerifyPinRespPars parser = new VerifyPinRespPars(new ApduResponse(ATTEMPTS_1, null), null); assertThat(parser.getRemainingAttemptCounter()).isEqualTo(1); parser.checkStatus(); shouldHaveThrown(CalypsoPoPinException.class); }
@Test(expected = CalypsoPoPinException.class) public void verifyPinRespPars_attempts_2() { VerifyPinRespPars parser = new VerifyPinRespPars(new ApduResponse(ATTEMPTS_2, null), null); assertThat(parser.getRemainingAttemptCounter()).isEqualTo(2); parser.checkStatus(); shouldHaveThrown(CalypsoPoPinException.class); }
@Test(expected = CalypsoPoPinException.class) public void verifyPinRespPars_pin_blocked() { VerifyPinRespPars parser = new VerifyPinRespPars(new ApduResponse(PIN_BLOCKED, null), null); assertThat(parser.getRemainingAttemptCounter()).isEqualTo(0); parser.checkStatus(); shouldHaveThrown(CalypsoPoPinException.class); }