AbstractOptimizer implements Optimizer { protected void nextIteration() throws TerminationException, StopException { completer.complete(population); archive.update(population); iteration.next(); for (OptimizerIterationListener listener : iterationListeners) { listener.iterationComplete(iteration.value()); } control.checkpointStop(); } AbstractOptimizer(Population population, Archive archive, IndividualCompleter completer, Control control,
			Iteration iteration); @Override int getIteration(); @Override boolean isRunning(); @Override void startOptimization(); @Override void stopOptimization(); @Override void addOptimizerIterationListener(OptimizerIterationListener listener); @Override void addOptimizerStateListener(OptimizerStateListener listener); @Override void removeOptimizerIterationListener(OptimizerIterationListener listener); @Override void removeOptimizerStateListener(OptimizerStateListener listener);  }
@Test public void nextIteration() throws TerminationException { final Control c = new Control(); Population p = new Population(); final Individual i1 = new MockIndividual(); p.add(i1); Archive a = new Archive() { @Override public boolean update(Set<? extends Individual> individuals) { archiveHasRun = true; Assert.assertTrue(individuals.contains(i1)); return true; } }; IndividualCompleter completer = new IndividualCompleter() { @Override public void complete(Individual... individuals) throws TerminationException { complete(Arrays.asList(individuals)); } @Override public void complete(Iterable<? extends Individual> iterable) throws TerminationException { completerHasRun = true; Assert.assertTrue(iterable.iterator().hasNext()); Assert.assertSame(i1, iterable.iterator().next()); } }; final MockOptimizer optimizer = new MockOptimizer(p, a, completer, c, new Iteration(10)); Assert.assertFalse(optimizer.isRunning()); optimizer.setOptimizeTest(new TestMethod() { @Override public void test() throws TerminationException, StopException { c.doStop(); c.checkpoint(); optimizer.nextIteration(); } }); optimizer.startOptimization(); Assert.assertFalse(optimizer.isRunning()); Assert.assertTrue(archiveHasRun); Assert.assertTrue(completerHasRun); }