SvDebitCmdBuild extends AbstractPoCommandBuilder<SvDebitRespPars> { public void finalizeBuilder(byte[] debitComplementaryData) { if ((poRevision == PoRevision.REV3_2 && debitComplementaryData.length != 20) || (poRevision != PoRevision.REV3_2 && debitComplementaryData.length != 15)) { throw new IllegalArgumentException("Bad SV prepare load data length."); } byte p1 = debitComplementaryData[4]; byte p2 = debitComplementaryData[5]; dataIn[0] = debitComplementaryData[6]; System.arraycopy(debitComplementaryData, 0, dataIn, 8, 4); System.arraycopy(debitComplementaryData, 7, dataIn, 12, 3); System.arraycopy(debitComplementaryData, 10, dataIn, 15, debitComplementaryData.length - 10); this.request = setApduRequest(poClass.getValue(), command, p1, p2, dataIn, null); } SvDebitCmdBuild(
      PoClass poClass, PoRevision poRevision, int amount, byte kvc, byte[] date, byte[] time); void finalizeBuilder(byte[] debitComplementaryData); byte[] getSvDebitData(); @Override SvDebitRespPars createResponseParser(ApduResponse apduResponse); @Override boolean isSessionBufferUsed();  }
@Test public void svDebitCmdBuild_mode_compat_base() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00BA55661477FFFF11223344AAAABBCCDD1234561122334455", apdu); }
@Test public void svDebitCmdBuild_mode_compat_4081() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, 4081, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00BA55661477F00F11223344AAAABBCCDD1234561122334455", apdu); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_compat_negative_amount() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, -1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_compat_overlimit_amount() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, 32768, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_compat_bad_signature_length_1() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_compat_bad_signature_length_2() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_1, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex("AABBCCDD556677123456112233")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test public void svDebitCmdBuild_mode_rev3_2_base() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00BA55661977FFFF11223344AAAABBCCDD12345611223344556677889900", apdu); }
@Test public void svDebitCmdBuild_mode_rev3_2_4081() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, 4081, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD55667712345611223344556677889900")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); Assert.assertEquals("00BA55661977F00F11223344AAAABBCCDD12345611223344556677889900", apdu); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_rev3_2_negative_amount() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, -1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_rev3_2_overlimit_amount() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, 32768, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_rev3_2_bad_signature_length_1() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex( "AABBCCDD5566771234561122334455")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }
@Test(expected = IllegalArgumentException.class) public void svDebitCmdBuild_mode_rev3_2_bad_signature_length_2() { SvDebitCmdBuild svDebitCmdBuild = new SvDebitCmdBuild( PoClass.ISO, PoRevision.REV3_2, 1, (byte) 0xAA, ByteArrayUtil.fromHex("1122"), ByteArrayUtil.fromHex("3344")); svDebitCmdBuild.finalizeBuilder( ByteArrayUtil.fromHex("AABBCCDD556677123456112233")); String apdu = ByteArrayUtil.toHex(svDebitCmdBuild.getApduRequest().getBytes()); }