SequentialIndividualCompleter implements IndividualCompleter { protected void evaluate(Individual individual) { State state = individual.getState(); if (state == State.PHENOTYPED) { individual.setState(State.EVALUATING); Object phenotype = individual.getPhenotype(); Objectives objectives = evaluator.evaluate(phenotype); assert isSameLength(objectives.getKeys()) : "Objectives changed: " + objectives.getKeys(); individual.setObjectives(objectives); } else { throw new IllegalStateException("Cannot evaluate Individual, current state: " + state); } } @Inject  SequentialIndividualCompleter(Control control, Decoder<Genotype, Object> decoder,
			Evaluator<Object> evaluator); @Override void complete(Iterable<? extends Individual> iterable); @Override void complete(Individual... individuals);  }
@Test public void evaluate() throws TerminationException { Injector injector = Guice.createInjector(new MockProblemModule()); IndividualFactory factory = injector.getInstance(IndividualFactory.class); Individual i1 = factory.create(); SequentialIndividualCompleter completer = injector.getInstance(SequentialIndividualCompleter.class); i1.setPhenotype("my phenotype"); Assert.assertTrue(i1.getState().equals(State.PHENOTYPED)); completer.evaluate(i1); Assert.assertTrue(i1.getState().equals(State.EVALUATED)); }
@Test(expected = IllegalStateException.class) public void evaluateEvaluated() throws TerminationException { Injector injector = Guice.createInjector(new MockProblemModule()); IndividualFactory factory = injector.getInstance(IndividualFactory.class); Individual i1 = factory.create(); SequentialIndividualCompleter completer = injector.getInstance(SequentialIndividualCompleter.class); i1.setPhenotype("my phenotype"); completer.evaluate(i1); completer.evaluate(i1); }
@Test(expected = AssertionError.class) public void evaluateDifferentObjectivesSize() throws TerminationException { Injector injector = Guice.createInjector(new MockProblemModule()); IndividualFactory factory = injector.getInstance(IndividualFactory.class); Individual i1 = factory.create(); Individual i2 = factory.create(); SequentialIndividualCompleter completer = injector.getInstance(SequentialIndividualCompleter.class); i1.setPhenotype("my phenotype"); i2.setPhenotype("my other phenotype"); completer.evaluate(i1); objectives.add(new Objective("y"), 4); completer.evaluate(i2); }