SantaFeAntTrailInterpreter implements FitnessFunction { Trail getTrail(final String trail_type) { final Trail trailTmp; if (trail_type.equals("geva.FitnessEvaluation.SantaFeAntTrail.Trail")) { trailTmp = new Trail(); } else if (trail_type.equals("geva.FitnessEvaluation.SantaFeAntTrail.SanMateoTrail")) { trailTmp = new SanMateoTrail(); } else if (trail_type.equals("geva.FitnessEvaluation.SantaFeAntTrail.LosAltosTrail")) { trailTmp = new LosAltosTrail(); } else { throw new IllegalArgumentException("Unkown trail type:" + trail_type + "\n Specify using " + SantaFeAntTrailInterpreter.TRAIL_TYPE_FLAG + " e.g the basic Santa Fe Trail: " + SantaFeAntTrailInterpreter.TRAIL_TYPE_FLAG + " geva.FitnessEvaluation.SantaFeAntTrail.Trail"); } return trailTmp; } SantaFeAntTrailInterpreter(); void setTrail_type(String trail_type); void getFitness(Individual individual); boolean canCache(); void setProperties(Properties p);  }
@Test public void testGetTrail() { System.out.println("* SantaFeAntTrailInterpreter: getTrail"); SantaFeAntTrailInterpreter instance = new SantaFeAntTrailInterpreter(); String trail_type = "geva.FitnessEvaluation.SantaFeAntTrail.Trail"; Trail trail = instance.getTrail(trail_type); assertEquals(true, trail.getClass().getName().equals(trail_type)); instance = new SantaFeAntTrailInterpreter(); trail_type = "geva.FitnessEvaluation.SantaFeAntTrail.SanMateoTrail"; trail = instance.getTrail(trail_type); assertEquals(true, trail.getClass().getName().equals(trail_type)); instance = new SantaFeAntTrailInterpreter(); trail_type = "geva.FitnessEvaluation.SantaFeAntTrail.LosAltosTrail"; trail = instance.getTrail(trail_type); assertEquals(true, trail.getClass().getName().equals(trail_type)); instance = new SantaFeAntTrailInterpreter(); trail_type = "geva.FitnessEvaluation.SantaFeAntTrail.Grr"; trail = null; try { trail = instance.getTrail(trail_type); } catch(IllegalArgumentException e) { assertTrue(true); } assertEquals(true, trail == null); }