@Test public void noKnownVersionReturnsSnapshotContainingCurrentMatchingLocks() { LockWatchReference entireTable = LockWatchReferenceUtils.entireTable(TABLE_REF); lockWatches.set(createWatchesFor(entireTable)); LockWatchStateUpdate update = log.getLogDiff(Optional.empty()); LockWatchStateUpdate.Snapshot snapshot = UpdateVisitors.assertSnapshot(update); assertThat(snapshot.lastKnownVersion()).isEqualTo(-1L); assertThat(snapshot.locked()).isEqualTo(ImmutableSet.of(DESCRIPTOR_2, DESCRIPTOR_3)); assertThat(snapshot.lockWatches()).containsExactly(entireTable); }
@Override public synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion) { return tryGetNextEvents(fromVersion).orElseGet(this::calculateSnapshot); }
LockEventLogImpl implements LockEventLog { @Override public synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion) { return tryGetNextEvents(fromVersion).orElseGet(this::calculateSnapshot); } }
LockEventLogImpl implements LockEventLog { @Override public synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion) { return tryGetNextEvents(fromVersion).orElseGet(this::calculateSnapshot); } LockEventLogImpl(UUID logId, Supplier<LockWatches> watchesSupplier, HeldLocksCollection heldLocksCollection); }
LockEventLogImpl implements LockEventLog { @Override public synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion) { return tryGetNextEvents(fromVersion).orElseGet(this::calculateSnapshot); } LockEventLogImpl(UUID logId, Supplier<LockWatches> watchesSupplier, HeldLocksCollection heldLocksCollection); @Override synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion); @Override synchronized ValueAndLockWatchStateUpdate<T> runTask(
            Optional<LockWatchVersion> lastKnownVersion, Supplier<T> task); @Override synchronized void logLock(Set<LockDescriptor> locksTakenOut, LockToken lockToken); @Override synchronized void logUnlock(Set<LockDescriptor> locksUnlocked); @Override synchronized void logLockWatchCreated(LockWatches newWatches); }
LockEventLogImpl implements LockEventLog { @Override public synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion) { return tryGetNextEvents(fromVersion).orElseGet(this::calculateSnapshot); } LockEventLogImpl(UUID logId, Supplier<LockWatches> watchesSupplier, HeldLocksCollection heldLocksCollection); @Override synchronized LockWatchStateUpdate getLogDiff(Optional<LockWatchVersion> fromVersion); @Override synchronized ValueAndLockWatchStateUpdate<T> runTask(
            Optional<LockWatchVersion> lastKnownVersion, Supplier<T> task); @Override synchronized void logLock(Set<LockDescriptor> locksTakenOut, LockToken lockToken); @Override synchronized void logUnlock(Set<LockDescriptor> locksUnlocked); @Override synchronized void logLockWatchCreated(LockWatches newWatches);  }