public void testExecution() throws Exception {
StorageTestUtil storageUtil = new StorageTestUtil(this);
storageUtil.expectOperations();
final ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
FakeScheduledExecutor executorClock =
FakeScheduledExecutor.scheduleAtFixedRateExecutor(executor, 2);
Clock mockClock = createMock(Clock.class);
expect(mockClock.nowMillis()).andReturn(2L).times(2);
expect(storageUtil.jobUpdateStore.pruneHistory(1, 1)).andReturn(ImmutableSet.of("id1", "id2"));
expect(storageUtil.jobUpdateStore.pruneHistory(1, 1)).andReturn(ImmutableSet.<String>of());
control.replay();
executorClock.assertEmpty();
JobUpdateHistoryPruner pruner = new JobUpdateHistoryPruner(
mockClock,
executor,
storageUtil.storage,
new HistoryPrunerSettings(
Amount.of(1L, Time.MILLISECONDS),
Amount.of(1L, Time.MILLISECONDS),
1));
pruner.execute();
executorClock.advance(Amount.of(2L, Time.MILLISECONDS));
executorClock.advance(Amount.of(1L, Time.MILLISECONDS));
}