SumDistinct extends DistinctAggregator { @Override public Object terminate() { double sum = 0; for (Object o : this.distinct) { sum += ((Number) o).doubleValue(); } return downCast(sum); }  @Override Object terminate();  }
@Test public void terminateShouldCorrectlyComputeDistinctValuesAddition() { distinctAggregator.accumulate(5); distinctAggregator.accumulate(10); distinctAggregator.accumulate(10); distinctAggregator.accumulate(15); Object result = distinctAggregator.terminate(); assertThat(result).isInstanceOf(Number.class); assertThat(((Number) result).intValue()).isEqualTo(30); }