@Test public void testHonorsMaxLatencyWhenGoingBackInTimeMultipleTimes() throws Throwable { this.timeProvider = mock(SlewClock.TimeProvider.class); final RuntimeException tooMuch = new RuntimeException("Querying time too often!"); long value; long lastValue = 101L; when(timeProvider.currentTimeMillis()).thenReturn(100L).thenThrow(tooMuch); SlewClock.realignWithTimeProvider(); verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 1); when(timeProvider.currentTimeMillis()).thenReturn(lastValue).thenThrow(tooMuch); value = assertLatencyIsLessThan(25); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 1); when(timeProvider.currentTimeMillis()).thenReturn(50L).thenThrow(tooMuch); value = assertLatencyIsLessThan(25); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 1); when(timeProvider.currentTimeMillis()).thenReturn(51L, 52L).thenThrow(tooMuch); value = assertLatencyIsLessThan(50); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 2); when(timeProvider.currentTimeMillis()).thenReturn(53L, 0L, 1L).thenThrow(tooMuch); value = assertLatencyIsLessThan(100); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 3); when(timeProvider.currentTimeMillis()).thenReturn(2L, 3L).thenThrow(tooMuch); value = assertLatencyIsLessThan(50); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 2); when(timeProvider.currentTimeMillis()).thenReturn(4L, 5L).thenThrow(tooMuch); value = assertLatencyIsLessThan(50); assertThat(value, greaterThanOrEqualTo(lastValue)); lastValue = value; verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 2); when(timeProvider.currentTimeMillis()).thenReturn(103L).thenThrow(tooMuch); value = assertLatencyIsLessThan(25); assertThat(value, greaterThanOrEqualTo(lastValue)); verifyCurrentTimeMillisInvocationsAndReset(timeProvider, 1); }
@Deprecated static void realignWithTimeProvider() { CURRENT.set(getCurrentTime()); }
SlewClock { @Deprecated static void realignWithTimeProvider() { CURRENT.set(getCurrentTime()); } }
SlewClock { @Deprecated static void realignWithTimeProvider() { CURRENT.set(getCurrentTime()); } private  SlewClock(); }
SlewClock { @Deprecated static void realignWithTimeProvider() { CURRENT.set(getCurrentTime()); } private  SlewClock();  }
SlewClock { @Deprecated static void realignWithTimeProvider() { CURRENT.set(getCurrentTime()); } private  SlewClock();   }