class 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);
  }

}

class SvReloadCmdBuildTest {

  @Test(expected = IllegalArgumentException.class)
  public void svReloadCmdBuild_mode_compat_bad_signature_length_1() {

    SvReloadCmdBuild svReloadCmdBuild =
        new SvReloadCmdBuild(
            PoClass.ISO,
            PoRevision.REV3_1,
            /* amount */ 1, /* KVC */
            (byte) 0xAA, /* date */
            ByteArrayUtil.fromHex("1122"),
            /* time */ ByteArrayUtil.fromHex("3344"), /* free */
            ByteArrayUtil.fromHex("F3EE"));
    svReloadCmdBuild.finalizeBuilder(
        /* SAM ID + prepare SV Reload data */ ByteArrayUtil.fromHex(
            "AABBCCDD55667712345611223344556677889900"));
  }

}