@Test
void testAllocationsUnique() {

    final Map<Long, String> allocated = new HashMap<>();
    try (FDBRecordContext context = database.openContext()) {
        HighContentionAllocator hca = new HighContentionAllocator(context, keySpace.path("test-path"));
        for (int i = 0; i < 50; i++) {
            String storedValue = "allocate-" + i;
            Long thisAllocation = hca.allocate(storedValue).join();
            assertThat("allocations are unique within a transaction", allocated, not(hasKey(thisAllocation)));
            allocated.put(thisAllocation, storedValue);
        }
        validateAllocation(context, hca, allocated);
        context.commit();
    }
    try (FDBRecordContext context = database.openContext()) {
        HighContentionAllocator hca = new HighContentionAllocator(context, keySpace.path("test-path"));
        validateAllocation(context, hca, allocated);
        for (int i = 0; i < 10; i++) {
            String storedValue = "new-allocate-" + i;
            Long newAllocation = hca.allocate(storedValue).join();
            assertThat("allocations are unique across transactions", allocated, not(hasKey(newAllocation)));
        }
    }
}