@Test
public void testResolveWithMetadata() {

    byte[] metadata = Tuple.from("some-metadata").pack();
    MetadataHook hook = ignore -> metadata;
    final ResolverResult result;
    final ResolverCreateHooks hooks = new ResolverCreateHooks(DEFAULT_CHECK, hook);
    result = globalScope.resolveWithMetadata("a-key", hooks).join();
    assertArrayEquals(metadata, result.getMetadata());
    // check that the result with metadata is persisted to the database
    ResolverResult expected = new ResolverResult(result.getValue(), metadata);
    try (FDBRecordContext context = database.openContext()) {
        ResolverResult resultFromDB = globalScope.mustResolveWithMetadata(context, "a-key").join();
        assertEquals(expected.getValue(), resultFromDB.getValue());
        assertArrayEquals(expected.getMetadata(), resultFromDB.getMetadata());
    }
    assertEquals(expected, globalScope.resolveWithMetadata("a-key", hooks).join());
    byte[] newMetadata = Tuple.from("some-different-metadata").pack();
    MetadataHook newHook = ignore -> newMetadata;
    final ResolverCreateHooks newHooks = new ResolverCreateHooks(DEFAULT_CHECK, newHook);
    // make sure we don't just read the cached value
    database.clearCaches();
    assertArrayEquals(metadata, globalScope.resolveWithMetadata("a-key", newHooks).join().getMetadata(),
            "hook is only run on create, does not update metadata");
}