PictureCopy implements FitnessFunction { public void setProperties(Properties p){ try{ if(p.getProperty(Constants.TARGET_IMAGE) != null && !p.getProperty(Constants.TARGET_IMAGE).equals("")){ targetImage =new String(p.getProperty(Constants.TARGET_IMAGE)); targetFile = new File(targetImage); if(!targetFile.exists()) targetFile = null; throw new BadParameterException(Constants.TARGET_IMAGE); } if(p.getProperty(Constants.TARGET_PHENOTYPE) != null && !p.getProperty(Constants.TARGET_PHENOTYPE).equals("")){ targetPhenotype = p.getProperty(Constants.TARGET_PHENOTYPE); } drawPhenotype = Boolean.parseBoolean(p.getProperty(Constants.DRAW_PHENOTYPE)); String grammarType = p.getProperty("image_grammar_type"); if (grammarType != null) { if (grammarType.equals("boolean_grammar")) { useShapeGrammar = false; } } } catch (BadParameterException e) { System.out.println("Error: File does not exist"); throw new IllegalArgumentException(Constants.TARGET_IMAGE); } init(); } PictureCopy();  PictureCopy(Properties p); void setProperties(Properties p); boolean canCache(); void getFitness(Individual i); void init(); void init(String name); static void main(String [] args); public Painting picture; }
@Test public void testSetProperties() { System.out.println("setProperties"); Properties p = new Properties(); p.setProperty(Constants.TARGET_PHENOTYPE,"UpDwn_( -20 ) symX_( 100 ) sqr"); PictureCopy instance = new PictureCopy(); instance.setProperties(p); assertEquals(true,instance.targetFile==null); p.setProperty(Constants.TARGET_IMAGE,"/Users/doesntExist"); try{ instance.setProperties(p); } catch(Exception e) { assertTrue(true); } assertEquals(true,instance.targetFile==null); }