@Test
public void testResolveWithWeakReadSemantics() {

    final boolean tracksReadVersions = database.isTrackLastSeenVersionOnRead();
    final boolean tracksCommitVersions = database.isTrackLastSeenVersionOnCommit();
    try {
        database.setTrackLastSeenVersionOnRead(true);
        database.setTrackLastSeenVersionOnCommit(false); // disable commit version tracking so that stale read version is cached
        final String key = "hello " + UUID.randomUUID();
        long resolvedValue;
        try (FDBRecordContext context = database.openContext()) {
            resolvedValue = globalScope.resolve(context, key).join();
        }
        // Clear the cache to ensure the database must be consulted
        database.clearCaches();
        // Using a stale read version should first read from the database, see that there is
        final FDBRecordContextConfig config = FDBRecordContextConfig.newBuilder()
                .setWeakReadSemantics(new FDBDatabase.WeakReadSemantics(0, Long.MAX_VALUE, true))
                .build();
        try (FDBRecordContext context = database.openContext(config)) {
            long resolvedAgainValue = globalScope.resolve(context, key).join();
            assertEquals(resolvedValue, resolvedAgainValue, "resolved value changed between transactions");
        }
    } finally {
        database.setTrackLastSeenVersionOnRead(tracksReadVersions);
        database.setTrackLastSeenVersionOnCommit(tracksCommitVersions);
    }
}