SvReloadCmdBuild extends AbstractPoCommandBuilder<SvReloadRespPars> { public void finalizeBuilder(byte[] reloadComplementaryData) { if ((poRevision == PoRevision.REV3_2 && reloadComplementaryData.length != 20) || (poRevision != PoRevision.REV3_2 && reloadComplementaryData.length != 15)) { throw new IllegalArgumentException("Bad SV prepare load data length."); } byte p1 = reloadComplementaryData[4]; byte p2 = reloadComplementaryData[5]; dataIn[0] = reloadComplementaryData[6]; System.arraycopy(reloadComplementaryData, 0, dataIn, 11, 4); System.arraycopy(reloadComplementaryData, 7, dataIn, 15, 3); System.arraycopy(reloadComplementaryData, 10, dataIn, 18, reloadComplementaryData.length - 10); this.request = setApduRequest(poClass.getValue(), command, p1, p2, dataIn, null); } SvReloadCmdBuild(
      PoClass poClass,
      PoRevision poRevision,
      int amount,
      byte kvc,
      byte[] date,
      byte[] time,
      byte[] free); void finalizeBuilder(byte[] reloadComplementaryData); byte[] getSvReloadData(); @Override SvReloadRespPars createResponseParser(ApduResponse apduResponse); @Override boolean isSessionBufferUsed();  }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_compat_overlimit_negative_amount() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_1, -8388609, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_compat_overlimit_positive_amount() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_1, 8388608, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_compat_bad_signature_length_1() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_1, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_compat_bad_signature_length_2() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_1, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex("AABBCCDD556677123456112233")); }
@Test public void svReloadCmdBuild_mode_rev3_2_amout_256() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, 256, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svReloadCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00B855661C771122F3AAEE0001003344AABBCCDD12345611223344556677889900", apdu); }
@Test public void svReloadCmdBuild_mode_rev3_2_amout_65536() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, 65536, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svReloadCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00B855661C771122F3AAEE0100003344AABBCCDD12345611223344556677889900", apdu); }
@Test public void svReloadCmdBuild_mode_rev3_2_amout_m1() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, -1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svReloadCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00B855661C771122F3AAEEFFFFFF3344AABBCCDD12345611223344556677889900", apdu); }
@Test public void svReloadCmdBuild_mode_rev3_2_amout_m256() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, -256, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svReloadCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00B855661C771122F3AAEEFFFF003344AABBCCDD12345611223344556677889900", apdu); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_rev3_2_overlimit_negative_amount() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, -8388609, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_rev3_2_overlimit_positive_amount() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, 8388608, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_rev3_2_bad_signature_length_1() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); }
@Test(expected = IllegalArgumentException.class) public void svReloadCmdBuild_mode_rev3_2_bad_signature_length_2() { SvReloadCmdBuild svReloadCmdBuild = new SvReloadCmdBuild( PoClass.ISO, PoRevision.REV3_2, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344"), ByteArrayUtil.fromHex("F3EE")); svReloadCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex("AABBCCDD5566771234561122")); }