JsonKeyEncoder { byte[] encode(final JsonNode record) { return ByteBuffer.allocate(Integer.BYTES).putInt(hasherSupplier.get().apply(record)).array(); } JsonKeyEncoder(Supplier<Path> pathSupplier); @VisibleForTesting  JsonKeyEncoder(Supplier<Path> pathSupplier, Random random);   }
@Test public void noPath() { JsonKeyEncoder encoder = new JsonKeyEncoder(() -> null, random); assertThat(encoder.encode(message), is(asBytes(RANDOM_VALUE))); }
@Test public void pathResolvesToMissingInMessage() { JsonKeyEncoder encoder = new JsonKeyEncoder(() -> KeyPathParser.parse("$.X"), random); assertThat(encoder.encode(message), is(asBytes(RANDOM_VALUE))); }
@Test public void pathResolvesToNullInMessage() { JsonKeyEncoder encoder = new JsonKeyEncoder(() -> KeyPathParser.parse("$.c"), random); assertThat(encoder.encode(message), is(asBytes(message.get("c").hashCode()))); }
@Test public void path() { JsonKeyEncoder encoder = new JsonKeyEncoder(() -> KeyPathParser.parse("$.a"), random); assertThat(encoder.encode(message), is(asBytes(message.get("a").hashCode()))); }