MeteredAdapter implements MetricAdapter { @Override public void updateMonitorables() { fifteenMinuteRate.set(metered.getFifteenMinuteRate()); fiveMinuteRate.set(metered.getFiveMinuteRate()); oneMinuteRate.set(metered.getOneMinuteRate()); meanRate.set(metered.getMeanRate()); count.set(metered.getCount()); } MeteredAdapter(Metered metered, String name, String description); @Override Set<Monitorable> getMonitorables(); @Override void updateMonitorables();  }
@Test public void shouldUpdateAllMonitorables() { long updatedCount = INITIAL_COUNT + 1; double updatedFifteenMinuteRate = INITIAL_FIFTEEN_MINUTE_RATE * 2.0; double updatedFiveMinuteRate = INITIAL_FIVE_MINUTE_RATE * 2.0; double updatedOneMinuteRate = INITIAL_ONE_MINUTE_RATE * 2.0; double updatedMeanRate = INITIAL_MEAN_RATE * 2.0; when(metered.getCount()).thenReturn(updatedCount); when(metered.getFifteenMinuteRate()).thenReturn(updatedFifteenMinuteRate); when(metered.getFiveMinuteRate()).thenReturn(updatedFiveMinuteRate); when(metered.getOneMinuteRate()).thenReturn(updatedOneMinuteRate); when(metered.getMeanRate()).thenReturn(updatedMeanRate); meteredAdapter.updateMonitorables(); assertThat(extractMonitorables(meteredAdapter).get(COUNT).get(), Matchers.<Object>is(updatedCount)); assertThat(extractMonitorables(meteredAdapter).get(FIFTEEN_MINUTE_RATE).get(), Matchers.<Object>is(updatedFifteenMinuteRate)); assertThat(extractMonitorables(meteredAdapter).get(FIVE_MINUTE_RATE).get(), Matchers.<Object>is(updatedFiveMinuteRate)); assertThat(extractMonitorables(meteredAdapter).get(ONE_MINUTE_RATE).get(), Matchers.<Object>is(updatedOneMinuteRate)); assertThat(extractMonitorables(meteredAdapter).get(MEAN_RATE).get(), Matchers.<Object>is(updatedMeanRate)); }