### Question:
Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } Average(); @SuppressWarnings("unused") // used by Jackson  Average(long value); @SuppressWarnings("unused") // used by Jackson  Average(double value);  Average(int count, Object value); void add(Long input); void addBatch(Long input, long dataPoints); void add(Double input); void addBatch(Double input, long dataPoints); @Override byte getStatType();  }### Answer:
@Test public void testLongAverage() { Average avg = new Average(); avg.add(2L); avg.add(4L); avg.add(4L); Assert.assertEquals(3L, avg.toLong()); }
@Test public void testDoubleAverage() { Average avg = new Average(); avg.add(2.0D); avg.add(4.0D); avg.add(4.0D); Assert.assertEquals(3.3333333333333335D, avg.toDouble(), 0); Assert.assertEquals(3.3333333333333335D, avg.toDouble(), 0); }