/** 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
  * creation of this <tt>HammerSummaryStats</tt>
  *
  * @return The Sum of all the stats in JSON.
  */
 public String getAggregateSumJSON() {
   String str =
       String.format(
           FakeUserStats.jsonMediaStreamStatsTemplate,
           -1, // ssrc not needed here
           aggregateDownloadJitterMs.getSum(),
           aggregateDownloadPercentLoss.getSum(),
           aggregateDownloadRateKiloBitPerSec.getSum(),
           aggregateJitterBufferDelayMs.getSum(),
           aggregateJitterBufferDelayPackets.getSum(),
           aggregateNbDiscarded.getSum(),
           aggregateNbDiscardedFull.getSum(),
           aggregateNbDiscardedLate.getSum(),
           aggregateNbDiscardedReset.getSum(),
           aggregateNbDiscardedShrink.getSum(),
           aggregateNbFec.getSum(),
           aggregateNbPackets.getSum(),
           aggregateNbPacketsLost.getSum(),
           aggregateNbReceivedBytes.getSum(),
           aggregateNbSentBytes.getSum(),
           aggregatePacketQueueCountPackets.getSum(),
           aggregatePacketQueueSize.getSum(),
           aggregatePercentDiscarded.getSum(),
           aggregateRttMs.getSum(),
           aggregateUploadJitterMs.getSum(),
           aggregateUploadPercentLoss.getSum(),
           aggregateUploadRateKiloBitPerSec.getSum());
   return str;
 }