public class MetricCalculatorTest extends EasyMockTest {
@Test
public void runTest() {
FakeClock clock = new FakeClock();
StatsProvider statsProvider = createMock(StatsProvider.class);
StatsProvider untracked = createMock(StatsProvider.class);
MetricCalculatorSettings settings = new MetricCalculatorSettings(10000);
StorageTestUtil storageUtil = new StorageTestUtil(this);
MetricCalculator calculator = new MetricCalculator(
storageUtil.storage,
clock,
settings,
statsProvider);
expect(statsProvider.untracked()).andReturn(untracked).anyTimes();
Capture<String> names = new Capture<>(CaptureType.ALL);
expect(untracked.makeGauge(EasyMock.capture(names), EasyMock.<Supplier<Number>>anyObject()))
.andReturn(EasyMock.<Stat<Number>>anyObject())
.anyTimes();
IScheduledTask task1 = makeTask(ImmutableMap.of(clock.nowMillis() - 1000, PENDING), 0);
IScheduledTask task2 = makeTask(ImmutableMap.of(clock.nowMillis() - 2000, PENDING), 1);
IScheduledTask task3 = makeTask(ImmutableMap.of(clock.nowMillis() - 3000, PENDING), 2);
IScheduledTask task4 = makeTask(ImmutableMap.of(clock.nowMillis() - 4000, PENDING), 3, false);
clock.advance(Amount.of(10L, Time.SECONDS));
storageUtil.expectTaskFetch(Query.unscoped(), task1, task2, task3, task4);
storageUtil.expectOperations();
control.replay();
calculator.run();