FromKeyDeserializer extends KeyValueDeserializer { @Override public Result deserializeKeyValue(byte[] key, byte[] value) { if (key == null) { throw new IllegalArgumentException("Expected a key but none provided"); } long ts = converter.toNanoseconds(fromBytes(key)); return new Result(ts, PcapHelper.addHeaders(ts, value, endianness), true); } FromKeyDeserializer(TimestampConverter converter); @Override Result deserializeKeyValue(byte[] key, byte[] value);  }
@Test public void empty_or_null_key_throws_illegal_argument_exception() { FromKeyDeserializer deserializer = new FromKeyDeserializer(TimestampConverters.NANOSECONDS); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> deserializer.deserializeKeyValue(null, null)); assertEquals("Expected a key but none provided", e.getMessage()); }