LegacyTimelockService implements TimelockService { @Override public Set<LockToken> unlock(Set<LockToken> tokens) { Set<LockToken> unlocked = Sets.newHashSet(); for (LockToken tokenV2 : tokens) { LockRefreshToken legacyToken = LockTokenConverter.toLegacyToken(tokenV2); if (lockService.unlock(legacyToken)) { unlocked.add(tokenV2); } } return unlocked; } LegacyTimelockService(TimestampService timestampService, LockService lockService,
            LockClient immutableTsLockClient); @Override boolean isInitialized(); @Override long getFreshTimestamp(); @Override long getCommitTimestamp(long startTs, LockToken commitLocksToken); @Override TimestampRange getFreshTimestamps(int numTimestampsRequested); @Override LockImmutableTimestampResponse lockImmutableTimestamp(); @Override List<StartIdentifiedAtlasDbTransactionResponse> startIdentifiedAtlasDbTransactionBatch(int count); @Override long getImmutableTimestamp(); @Override LockResponse lock(LockRequest request); @Override WaitForLocksResponse waitForLocks(WaitForLocksRequest request); @Override Set<LockToken> refreshLockLeases(Set<LockToken> tokens); @Override Set<LockToken> unlock(Set<LockToken> tokens); @Override void tryUnlock(Set<LockToken> tokens); @Override long currentTimeMillis();  }
@Test public void unlockDelegatesToLockService() { timelock.unlock(ImmutableSet.of(LOCK_TOKEN_V2)); verify(lockService).unlock(LOCK_REFRESH_TOKEN); }
@Test public void unlockReturnsSubsetThatWereUnlocked() { LockToken tokenA = randomLockToken(); LockToken tokenB = randomLockToken(); when(lockService.unlock(toLegacyToken(tokenA))).thenReturn(true); when(lockService.unlock(toLegacyToken(tokenB))).thenReturn(false); Set<LockToken> expected = ImmutableSet.of(tokenA); assertThat(timelock.unlock(ImmutableSet.of(tokenA, tokenB))).isEqualTo(expected); }