@Test
void testInterningConcurrent() {

    Map<String, Long> allocations;
    try (FDBRecordContext context = database.openContext()) {
        StringInterningLayer interningLayer = new StringInterningLayer(testSubspace);
        List<CompletableFuture<Pair<String, Long>>> futures = IntStream.range(0, 50)
                .mapToObj(i -> String.format("intern-%d", i))
                .map(value -> interningLayer.intern(context, value).thenApply(interned -> Pair.of(value, interned.getValue())))
                .collect(Collectors.toList());
        allocations = AsyncUtil.getAll(futures).join().stream()
                .collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
        for (int i = 0; i < 50; i++) {
            String toIntern = "intern-" + i;
            Long value = interningLayer.intern(context, toIntern).join().getValue();
            assertThat("value is in mapping", allocations.get(toIntern), is(value));
        }
    }
}