CPLCUtils { public static CPLC parse(byte[] raw) { CPLC ret = null; if (raw != null) { byte[] cplc = null; if (raw.length == CPLC.SIZE + 2) { cplc = raw; } else if (raw.length == CPLC.SIZE + 5) { cplc = TlvUtil.getValue(raw, CPLC_TAG); } else { LOGGER.error("CPLC data not valid"); return null; } ret = new CPLC(); ret.parse(cplc,null); } return ret; } private  CPLCUtils(); static CPLC parse(byte[] raw);  }
@Test public void testEmptyCPLC(){ CPLC cplc = CPLCUtils.parse(null); Assertions.assertThat(cplc).isNull(); }
@Test public void testErrorCPLC(){ CPLC cplc = CPLCUtils.parse(BytesUtils.fromString("69 85")); Assertions.assertThat(cplc).isNull(); }
@Test public void testRawDataCPLC(){ SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); CPLC cplc = CPLCUtils.parse(BytesUtils.fromString("47 90 50 40 47 91 81 02 31 00 83 58 00 11 68 91 45 81 48 12 83 65 00 00 00 00 01 2F 31 30 31 31 36 38 00 00 00 00 00 00 00 00 90 00")); Assertions.assertThat(cplc).isNotNull(); Assertions.assertThat(cplc.getIcFabricator()).isEqualTo(0x4790); Assertions.assertThat(cplc.getIcType()).isEqualTo(0x5040); Assertions.assertThat(cplc.getOs()).isEqualTo(0x4791); Assertions.assertThat(cplc.getOsReleaseLevel()).isEqualTo(0x3100); Assertions.assertThat(cplc.getIcSerialNumber()).isEqualTo(0x00116891); Assertions.assertThat(cplc.getIcBatchId()).isEqualTo(0x4581); Assertions.assertThat(cplc.getIcModuleFabricator()).isEqualTo(0x4812); Assertions.assertThat(cplc.getIccManufacturer()).isEqualTo(0x0000); Assertions.assertThat(cplc.getIcEmbeddingDate()).isNull(); Assertions.assertThat(cplc.getPrepersoId()).isEqualTo(0x012F); Assertions.assertThat(cplc.getPrepersoEquipment()).isEqualTo(0x31313638); Assertions.assertThat(cplc.getPersoId()).isEqualTo(0x0000); Assertions.assertThat(cplc.getPersoEquipment()).isEqualTo(0x0000); Assertions.assertThat(format.format(cplc.getOsReleaseDate())).isEqualTo("12/04/2018"); Assertions.assertThat(format.format(cplc.getIcFabricDate())).isEqualTo("24/12/2018"); Assertions.assertThat(format.format(cplc.getPrepersoDate())).isEqualTo("10/05/2013"); Assertions.assertThat(format.format(cplc.getIcPackagingDate())).isEqualTo("31/12/2018"); Assertions.assertThat(cplc.getPersoDate()).isNull(); }
@Test public void testPrependedCPLC(){ CPLC cplc = CPLCUtils.parse(BytesUtils.fromString("9F 7F 2A 47 90 50 40 47 91 81 02 31 00 83 58 00 11 68 91 45 81 48 12 83 65 00 00 00 00 01 2F 31 30 31 31 36 38 00 00 00 00 00 00 00 00 90 00")); Assertions.assertThat(cplc).isNotNull(); Assertions.assertThat(cplc.getIcFabricator()).isEqualTo(0x4790); Assertions.assertThat(cplc.getIcType()).isEqualTo(0x5040); Assertions.assertThat(cplc.getOs()).isEqualTo(0x4791); Assertions.assertThat(cplc.getOsReleaseLevel()).isEqualTo(0x3100); Assertions.assertThat(cplc.getIcSerialNumber()).isEqualTo(0x00116891); Assertions.assertThat(cplc.getIcBatchId()).isEqualTo(0x4581); Assertions.assertThat(cplc.getIcModuleFabricator()).isEqualTo(0x4812); Assertions.assertThat(cplc.getIccManufacturer()).isEqualTo(0x0000); Assertions.assertThat(cplc.getIcEmbeddingDate()).isNull(); Assertions.assertThat(cplc.getPrepersoId()).isEqualTo(0x012F); Assertions.assertThat(cplc.getPrepersoEquipment()).isEqualTo(0x31313638); Assertions.assertThat(cplc.getPersoId()).isEqualTo(0x0000); Assertions.assertThat(cplc.getPersoEquipment()).isEqualTo(0x0000); }