FitnessEvaluationOperation implements Operation { public void setProperties(Properties p) { String value = p.getProperty(Constants.POPULATION_SIZE); try { populationSize = Integer.parseInt(value); originalPopulationSize = populationSize; } catch (NumberFormatException e) { populationSize = Integer.parseInt(Constants.DEFAULT_POPULATION_SIZE); } } FitnessEvaluationOperation(FitnessFunction ff); int getPopulationSize(); void setPopulationSize(int populationSize); void doOperation(Individual operand); void setProperties(Properties p); int getOriginalPopulationSize(); void doOperation(List<Individual> operands); FitnessFunction getFitnessFunction();  }
@Test public void testSetProperties() { System.out.println("* FitnessEvaluationOperation: setProperties"); Properties p = GrammarCreator.getProperties(); p.setProperty(Constants.POPULATION_SIZE, "10"); FitnessEvaluationOperation instance = new FitnessEvaluationOperation(null); instance.setProperties(p); assertEquals(instance.getPopulationSize(), 10); assertEquals(instance.getOriginalPopulationSize(), 10); p = GrammarCreator.getProperties(); p.setProperty(Constants.POPULATION_SIZE, "a"); instance = new FitnessEvaluationOperation(null); instance.setProperties(p); assertEquals(instance.getPopulationSize(), Integer.parseInt(Constants.DEFAULT_POPULATION_SIZE)); assertEquals(instance.getOriginalPopulationSize(), 0); }