@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return timestampService.getFreshTimestamps(numTimestampsRequested); }
@Override public void close() { lockRefresher.close(); unlocker.close(); timestampService.close(); }
@Override public long getFreshTimestamp() { return timestampService.getFreshTimestamp(); }
@Override public boolean isInitialized() { return delegate.isInitialized() && timestampService.isInitialized(); }
@Test public void delegatesInitializationCheck() { when(delegate.isInitialized()) .thenReturn(false) .thenReturn(true); when(timestampService.isInitialized()).thenReturn(true); assertFalse(timelock.isInitialized()); assertTrue(timelock.isInitialized()); }
@Test public void throwsIfAskForZeroTimestamps() { assertThatThrownBy(() -> timestamp.getFreshTimestamps(0)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Must not request zero or negative timestamps"); }
@Override public boolean isInitialized() { return delegate.isInitialized() && timestampService.isInitialized(); }
@After public void after() { timestamp.close(); }
@Test public void getTimestampDelegates() { long timestamp = 123L; when(timestampService.getFreshTimestamp()).thenReturn(timestamp); assertThat(timelock.getFreshTimestamp()).isEqualTo(timestamp); }
@Test public void getTimestampsDelegates() { int numTimestamps = 5; TimestampRange timestamps = TimestampRange.createInclusiveRange(1L, numTimestamps); when(timestampService.getFreshTimestamps(numTimestamps)).thenReturn(timestamps); assertThat(timelock.getFreshTimestamps(numTimestamps)).isEqualTo(timestamps); }
@Override public void close() { lockRefresher.close(); unlocker.close(); timestampService.close(); }
@Override public long getFreshTimestamp() { return timestampService.getFreshTimestamp(); }
@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { return timestampService.getFreshTimestamps(numTimestampsRequested); }