AbstractIndividualFactory implements IndividualFactory { @Override public void removeIndividualStateListener(IndividualStateListener listener) { individualStateListeners.remove(listener); } 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 removeIndividualStateListenerTest() { AbstractIndividualFactory<Individual> factory = getFactory(); IndividualStateListener listener2 = new IndividualStateListener() { @Override public void inidividualStateChanged(Individual individual) { } }; factory.addIndividualStateListener(listener2); Assert.assertTrue(factory.individualStateListeners.contains(listener2)); factory.removeIndividualStateListener(listener2); Assert.assertFalse(factory.individualStateListeners.contains(listener2)); }