### Question:
WeightedSnapshot extends Snapshot { @Override public long getMax() { if (values.length == 0) { return 0; } return values[values.length - 1]; } WeightedSnapshot(Collection<WeightedSample> values); @Override double getValue(double quantile); @Override int size(); @Override long[] getValues(); @Override long getMax(); @Override long getMin(); @Override double getMean(); @Override double getStdDev(); @Override void dump(OutputStream output);  }### Answer:
@Test public void calculatesTheMaximumValue() { assertThat(snapshot.getMax()) .isEqualTo(5); }
@Test public void calculatesAMaxOfZeroForAnEmptySnapshot() { final Snapshot emptySnapshot = new WeightedSnapshot( weightedArray(new long[]{}, new double[]{})); assertThat(emptySnapshot.getMax()) .isZero(); }