@Test
public void testScopedDirectoryLayerResolvesWithoutMetadata() {

    MetadataHook hook = name -> Tuple.from("metadata-for-" + name).pack();
    ResolverCreateHooks createHooks = new ResolverCreateHooks(ResolverCreateHooks.DEFAULT_CHECK, hook);
    ResolverResult result = globalScope.resolveWithMetadata("some-key", createHooks).join();
    assertArrayEquals(Tuple.from("metadata-for-some-key").pack(), result.getMetadata(), "metadata was added");
    ResolverResult resultFromScoped = ScopedDirectoryLayer.global(database)
            .resolveWithMetadata("some-key", /* no hooks */ ResolverCreateHooks.getDefault())
            .join();
    assertEquals(resultFromScoped.getValue(), result.getValue());
    assertThat(resultFromScoped.getMetadata(), is(nullValue()));
    try (FDBRecordContext context = database.openContext()) {
        assertArrayEquals(globalScope.mustResolveWithMetadata(context, "some-key").join().getMetadata(),
                Tuple.from("metadata-for-some-key").pack(),
                "we can still read the metadata with " + globalScope.getClass().getName());
    }
}