use of org.eclipse.collections.api.set.primitive.IntSet in project eclipse-collections by eclipse.
the class PersonAndPetKataTest method getAgeStatisticsOfPets.
@Test
public void getAgeStatisticsOfPets() {
IntList ages = this.people.asLazy().flatCollect(Person::getPets).collectInt(Pet::getAge).toList();
IntSet uniqueAges = ages.toSet();
IntSummaryStatistics stats = ages.summaryStatistics();
Assert.assertEquals(IntHashSet.newSetWith(1, 2, 3, 4), uniqueAges);
Assert.assertEquals(stats.getMin(), ages.min());
Assert.assertEquals(stats.getMax(), ages.max());
Assert.assertEquals(stats.getSum(), ages.sum());
Assert.assertEquals(stats.getAverage(), ages.average(), 0.0);
Assert.assertEquals(stats.getCount(), ages.size());
Assert.assertTrue(ages.allSatisfy(IntPredicates.greaterThan(0)));
Assert.assertTrue(ages.allSatisfy(i -> i > 0));
Assert.assertFalse(ages.anySatisfy(IntPredicates.equal(0)));
Assert.assertFalse(ages.anySatisfy(i -> i == 0));
Assert.assertTrue(ages.noneSatisfy(IntPredicates.lessThan(0)));
Assert.assertTrue(ages.noneSatisfy(i -> i < 0));
Assert.assertEquals(2.0d, ages.median(), 0.0);
}
Aggregations