DecodeUnsigned64 implements IpfixDataRecordDecodeMethod { @Override public String decodeDataRecord(byte[] data, int length) throws UtilityException, DataTypeLengthMismatchException { if (length != LENGTH) { throw new DataTypeLengthMismatchException("Incorrect length for Unsigned64 type: " + length); } data = IpfixUtilities.copyByteArray(data, 0, LENGTH); return Long.toString((IpfixUtilities.bytesToLong(data, 1, LENGTH))); }  @Override String decodeDataRecord(byte[] data, int length);  }
@Test public void testDecodeUnsigned64() throws UtilityException, DataTypeLengthMismatchException, UnknownHostException, MissingAbstractDataTypeException { byte[] data = IpfixUtilities.hexStringToByteArray("000000000000006F"); int length = 8; IpfixDataRecordDecodeMethod method = new DecodeUnsigned64(); String value = method.decodeDataRecord(data, length); assertEquals("111", value); }
@Test(expected = DataTypeLengthMismatchException.class) public void testDecodeUnsigned64LengthMismatch() throws UtilityException, DataTypeLengthMismatchException, UnknownHostException, MissingAbstractDataTypeException { byte[] data = IpfixUtilities.hexStringToByteArray("000000000000006F"); int length = 9; IpfixDataRecordDecodeMethod method = new DecodeUnsigned64(); String value = method.decodeDataRecord(data, length); assertEquals("111", value); }