AbstractIndividualFactory implements IndividualFactory { @Override public Individual create() { Individual individual = individualProvider.get(); individual.setIndividualStatusListeners(individualStateListeners); Genotype genotype = creator.create(); individual.setGenotype(genotype); return individual; } AbstractIndividualFactory(Provider<I> individualProvider, Creator<Genotype> creator); @Override void addIndividualStateListener(IndividualStateListener listener); @Override Individual create(); @Override Individual create(Genotype genotype); @Override void removeIndividualStateListener(IndividualStateListener listener);  }
@Test public void createTest() { AbstractIndividualFactory<Individual> factory = getFactory(); init(factory); Individual individual = factory.create(); Assert.assertTrue(individual.individualStateListeners.contains(listener)); Assert.assertNotNull(individual.genotype); }
@Test public void createWithGenotypeTest() { AbstractIndividualFactory<Individual> factory = getFactory(); init(factory); Genotype genotype = new PermutationGenotype<Object>(); Individual individual = factory.create(genotype); Assert.assertTrue(individual.individualStateListeners.contains(listener)); Assert.assertTrue(individual.genotype == genotype); }