SamplingAdapter implements MetricAdapter { @Override public void updateMonitorables() { Snapshot snapshot = samplingMetric.getSnapshot(); mean.set(snapshot.getMean()); median.set(snapshot.getMedian()); max.set(snapshot.getMax()); min.set(snapshot.getMin()); stddev.set(snapshot.getStdDev()); seventyFifthPercentile.set(snapshot.get75thPercentile()); ninetyFifthPercentile.set(snapshot.get95thPercentile()); ninetyEighthPercentile.set(snapshot.get98thPercentile()); ninetyNinthPercentile.set(snapshot.get99thPercentile()); threeNinesPercentile.set(snapshot.get999thPercentile()); } SamplingAdapter(Sampling samplingMetric, String name, String description, Unit<?> unit);  SamplingAdapter(Sampling samplingMetric, String name, String description); @Override Set<Monitorable> getMonitorables(); @Override void updateMonitorables();  }
@Test public void shouldUpdateMinMetric() { long newMin = INITIAL_MIN - 5; when(snapshot.getMin()).thenReturn(newMin); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(MIN).get(), Matchers.<Object>is(newMin)); }
@Test public void shouldUpdateMaxMetric() { long newMax = INITIAL_MAX + 5; when(snapshot.getMax()).thenReturn(newMax); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(MAX).get(), Matchers.<Object>is(newMax)); }
@Test public void shouldUpdateMeanMetric() { double newMean = INITIAL_MEAN + 5; when(snapshot.getMean()).thenReturn(newMean); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(MEAN).get(), Matchers.<Object>is(newMean)); }
@Test public void shouldUpdateMedianMetric() { double newMedian = INITIAL_MEDIAN + 5; when(snapshot.getMedian()).thenReturn(newMedian); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(MEDIAN).get(), Matchers.<Object>is(newMedian)); }
@Test public void shouldUpdateStdDevMetric() { double newStdDev = INITIAL_STDDEV + 5; when(snapshot.getStdDev()).thenReturn(newStdDev); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(STDDEV).get(), Matchers.<Object>is(newStdDev)); }
@Test public void shouldUpdate75thMetric() { double new75thMetric = INITIAL_75th + 5; when(snapshot.get75thPercentile()).thenReturn(new75thMetric); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(SEVENTY_FIFTH).get(), Matchers.<Object>is(new75thMetric)); }
@Test public void shouldUpdate95thMetric() { double new95thMetric = INITIAL_95th + 5; when(snapshot.get95thPercentile()).thenReturn(new95thMetric); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(NINETY_FIFTH).get(), Matchers.<Object>is(new95thMetric)); }
@Test public void shouldUpdate98thMetric() { double new98thMetric = INITIAL_98th + 5; when(snapshot.get98thPercentile()).thenReturn(new98thMetric); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(NINETY_EIGHTH).get(), Matchers.<Object>is(new98thMetric)); }
@Test public void shouldUpdate99thMetric() { double new99thMetric = INITIAL_99th + 5; when(snapshot.get99thPercentile()).thenReturn(new99thMetric); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(NINETY_NINETH).get(), Matchers.<Object>is(new99thMetric)); }
@Test public void shouldUpdate999thMetric() { double new999thMetric = INITIAL_THREE_NINES + 5; when(snapshot.get999thPercentile()).thenReturn(new999thMetric); adapter.updateMonitorables(); assertThat(extractMonitorables(adapter).get(THREE_NINES).get(), Matchers.<Object>is(new999thMetric)); }