EliteOperationSelection extends SelectionOperation { @Override public void setProperties(Properties p) { int value =0; String key = Constants.ELITE_SIZE; value = Integer.parseInt(p.getProperty(key,"0")); if (value == -1) { value = 0; } this.size = value; String valueS; key = Constants.EVALUATE_ELITES; try { valueS = p.getProperty(key); if(valueS == null ) { valueS = Constants.FALSE; } } catch(Exception e) { valueS = Constants.FALSE; logger.warn(e+" using default: "+valueS); } this.evaluate_elites = valueS.equals(Constants.TRUE); super.selectedPopulation = new SimplePopulation(this.size); } EliteOperationSelection(int size);  EliteOperationSelection(Properties p); @Override void setProperties(Properties p); boolean isEvaluateElites(); void doOperation(Individual operand); void doOperation(List<Individual> operands); void setEvaluate_elites(boolean evaluate_elites);  }
@Test public void testSetProperties() { System.out.println("* EliteOperationSelection: setProperties"); Properties p = GrammarCreator.getProperties(); p.setProperty(Constants.ELITE_SIZE, "1"); p.setProperty(Constants.EVALUATE_ELITES, "true"); EliteOperationSelection instance = new EliteOperationSelection(0); instance.setProperties(p); assertEquals(instance.size, Integer.parseInt(p.getProperty(Constants.ELITE_SIZE))); assertEquals(instance.isEvaluateElites(), Boolean.parseBoolean(p.getProperty(Constants.EVALUATE_ELITES))); assertEquals(instance.getSelectedPopulation().size(), 0); instance = new EliteOperationSelection(0); p.setProperty(Constants.ELITE_SIZE, "-1"); p.setProperty(Constants.EVALUATE_ELITES, ""); instance.setProperties(p); assertEquals(instance.size, 0); assertEquals(instance.isEvaluateElites(), false); assertEquals(instance.getSelectedPopulation().size(), 0); }