/** 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)); }