/** Tests the standard aggregation behavior */
  @Test
  public void testAggregation() {
    AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
    SummaryStatistics setOneStats = aggregate.createContributingStatistics();
    SummaryStatistics setTwoStats = aggregate.createContributingStatistics();

    Assert.assertNotNull("The set one contributing stats are null", setOneStats);
    Assert.assertNotNull("The set two contributing stats are null", setTwoStats);
    Assert.assertNotSame("Contributing stats objects are the same", setOneStats, setTwoStats);

    setOneStats.addValue(2);
    setOneStats.addValue(3);
    setOneStats.addValue(5);
    setOneStats.addValue(7);
    setOneStats.addValue(11);
    Assert.assertEquals("Wrong number of set one values", 5, setOneStats.getN());
    Assert.assertTrue(
        "Wrong sum of set one values", Precision.equals(28.0, setOneStats.getSum(), 1));

    setTwoStats.addValue(2);
    setTwoStats.addValue(4);
    setTwoStats.addValue(8);
    Assert.assertEquals("Wrong number of set two values", 3, setTwoStats.getN());
    Assert.assertTrue(
        "Wrong sum of set two values", Precision.equals(14.0, setTwoStats.getSum(), 1));

    Assert.assertEquals("Wrong number of aggregate values", 8, aggregate.getN());
    Assert.assertTrue("Wrong aggregate sum", Precision.equals(42.0, aggregate.getSum(), 1));
  }
 /**
  * Get the Sum of all the stats that are watched, for all the stats added with add() since the
  * last call to clear() in JSON.
  *
  * @return The Sum of all the stats since last clear() in JSON.
  */
 public String getSumJSON() {
   String str =
       String.format(
           FakeUserStats.jsonMediaStreamStatsTemplate,
           -1, // ssrc not needed here
           downloadJitterMs.getSum(),
           downloadPercentLoss.getSum(),
           downloadRateKiloBitPerSec.getSum(),
           jitterBufferDelayMs.getSum(),
           jitterBufferDelayPackets.getSum(),
           nbDiscarded.getSum(),
           nbDiscardedFull.getSum(),
           nbDiscardedLate.getSum(),
           nbDiscardedReset.getSum(),
           nbDiscardedShrink.getSum(),
           nbFec.getSum(),
           nbPackets.getSum(),
           nbPacketsLost.getSum(),
           nbReceivedBytes.getSum(),
           nbSentBytes.getSum(),
           packetQueueCountPackets.getSum(),
           packetQueueSize.getSum(),
           percentDiscarded.getSum(),
           rttMs.getSum(),
           uploadJitterMs.getSum(),
           uploadPercentLoss.getSum(),
           uploadRateKiloBitPerSec.getSum());
   return str;
 }