TimerAdapter implements MetricAdapter { @Override public void updateMonitorables() { meteredAdapter.updateMonitorables(); samplingAdapter.updateMonitorables(); } TimerAdapter(Timer timer, String name, String description); @Override Set<Monitorable> getMonitorables(); @Override void updateMonitorables();  }
@Test public void shouldUpdateCountMetric() { long newCount = INITIAL_COUNT + 10; when(timer.getCount()).thenReturn(newCount); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(COUNT).get(), Matchers.<Object>is(newCount)); }
@Test public void shouldUpdateMinMetric() { long newMin = INITIAL_MIN + 10; when(snapshot.getMin()).thenReturn(newMin); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(MIN).get(), Matchers.<Object>is(newMin)); }
@Test public void shouldUpdateMaxMetric() { long newMax = INITIAL_MAX + 10; when(snapshot.getMax()).thenReturn(newMax); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(MAX).get(), Matchers.<Object>is(newMax)); }
@Test public void shouldUpdateMeanMetric() { double newMean = INITIAL_MEAN + 10; when(snapshot.getMean()).thenReturn(newMean); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(MEAN).get(), Matchers.<Object>is(newMean)); }
@Test public void shouldUpdateMedianMetric() { double newMedian = INITIAL_MEDIAN + 10; when(snapshot.getMedian()).thenReturn(newMedian); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(MEDIAN).get(), Matchers.<Object>is(newMedian)); }
@Test public void shouldUpdateStdDevMetric() { double newStdDev = INITIAL_STDDEV + 10; when(snapshot.getStdDev()).thenReturn(newStdDev); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(STDDEV).get(), Matchers.<Object>is(newStdDev)); }
@Test public void shouldUpdateFifteenMinuteRateMetric() { double newFifteenMinute = INITIAL_FIFTEEN_MINUTE_RATE + 10; when(timer.getFifteenMinuteRate()).thenReturn(newFifteenMinute); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(FIFTEEN_MINUTE_RATE).get(), Matchers.<Object>is(newFifteenMinute)); }
@Test public void shouldUpdateFiveMinuteRateMetric() { double newFiveMinute = INITIAL_FIVE_MINUTE_RATE + 10; when(timer.getFiveMinuteRate()).thenReturn(newFiveMinute); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(FIVE_MINUTE_RATE).get(), Matchers.<Object>is(newFiveMinute)); }
@Test public void shouldUpdateOneMinuteRateMetric() { double newOneMinute = INITIAL_ONE_MINUTE_RATE + 10; when(timer.getOneMinuteRate()).thenReturn(newOneMinute); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(ONE_MINUTE_RATE).get(), Matchers.<Object>is(newOneMinute)); }
@Test public void shouldUpdateMeanRateMetric() { double newMeanRate = INITIAL_MEAN_RATE + 10; when(timer.getMeanRate()).thenReturn(newMeanRate); timerAdapter.updateMonitorables(); assertThat(extractMonitorables(timerAdapter).get(MEAN_RATE).get(), Matchers.<Object>is(newMeanRate)); }