@Test
public void aggregateBy()
{

    Function2<Integer, Integer, Integer> countAggregator = new Function2<Integer, Integer, Integer>()
    {
        public Integer value(Integer aggregate, Integer value)
        {
            return aggregate + 1;
        }
    };
    List<Integer> list = Interval.oneTo(20000);
    MutableMap<String, Integer> aggregation =
            FJIterate.aggregateBy(list, EVEN_OR_ODD, INTEGER_NEW, countAggregator);
    Assert.assertEquals(10000, aggregation.get("Even").intValue());
    Assert.assertEquals(10000, aggregation.get("Odd").intValue());
    FJIterate.aggregateBy(list, EVEN_OR_ODD, INTEGER_NEW, countAggregator, aggregation);
    Assert.assertEquals(20000, aggregation.get("Even").intValue());
    Assert.assertEquals(20000, aggregation.get("Odd").intValue());
}