### Question:
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoir();  SlidingWindowHistogramReservoir(SlidingWindowHistogram histogram);  SlidingWindowHistogramReservoir(SlidingWindowHistogram histogram, Clock clock); @Override int size(); @Override synchronized void update(long value); @Override synchronized Snapshot getSnapshot();  }### Answer:
@Test public void snapshotComputesPercentiles() { SlidingWindowHistogramReservoir reservoir = reservoirWithSamples(1, 100); assertThat(reservoir.getSnapshot().getMin(), is(1L)); assertThat(reservoir.getSnapshot().getMax(), is(100L)); assertThat(reservoir.getSnapshot().getMean(), is(closeTo(50.5, 1))); assertThat(reservoir.getSnapshot().get75thPercentile(), is(closeTo(75, 0.5))); assertThat(reservoir.getSnapshot().get95thPercentile(), is(closeTo(95, 0.5))); assertThat(reservoir.getSnapshot().get98thPercentile(), is(closeTo(98, 0.5))); assertThat(reservoir.getSnapshot().get99thPercentile(), is(closeTo(99, 0.5))); assertThat(reservoir.getSnapshot().getMedian(), is(closeTo(50L, 1))); }
@Test public void snapshotExposesSamplesAsArray() { SlidingWindowHistogramReservoir reservoir = reservoirWithSamples(1, 100); assertThat(reservoir.getSnapshot().getValues(), is(toArray(Range.closed(1L, 100L)))); }