UnboundedArchive extends AbstractArchive { @Override protected boolean updateWithNondominated(Collection<Individual> candidates) { boolean changed = false; for (Individual i : candidates) { if (!contains(i)) { changed |= addCheckedIndividual(i); } } return changed; }    }
@Test public void updateWithNondominated() { Individual individual = mock(Individual.class); UnboundedArchive archive = new UnboundedArchive(); Assert.assertFalse(archive.iterator().hasNext()); Assert.assertTrue(archive.updateWithNondominated(Collections.singleton(individual))); Assert.assertTrue(archive.iterator().hasNext()); Assert.assertEquals(archive.iterator().next(), individual); }
@Test public void updateWithExisting() { Individual individual = mock(Individual.class); UnboundedArchive archive = new UnboundedArchive(); archive.updateWithNondominated(Collections.singleton(individual)); Assert.assertFalse(archive.updateWithNondominated(Collections.singleton(individual))); }
@Test public void updateWithNone() { UnboundedArchive archive = new UnboundedArchive(); Assert.assertFalse(archive.updateWithNondominated(Collections.<Individual> emptySet())); }