/** * @author mrieser */ public void testGetBestPlan_allWithoutScore() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); Plan p2 = PopulationUtils.createPlan(); person.addPlan(p1); person.addPlan(p2); Plan p = new BestPlanSelector<Plan, Person>().selectPlan(person); assertTrue(p == p1 || p == p2); } }
/** * @author mrieser */ public void testGetBestPlan_oneWithoutScore() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); Plan p2 = PopulationUtils.createPlan(); p2.setScore(80.0); person.addPlan(p1); person.addPlan(p2); Plan p = new BestPlanSelector<Plan, Person>().selectPlan(person); assertEquals(p2, p); }
/** * @author mrieser */ public void testGetBestPlan() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); p1.setScore(90.0); Plan p2 = PopulationUtils.createPlan(); p2.setScore(89.0); person.addPlan(p1); person.addPlan(p2); Plan p = new BestPlanSelector<Plan, Person>().selectPlan(person); assertEquals(p1, p); }
/** * @author mrieser */ public void testGetBestPlan_multipleBest() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); p1.setScore(11.0); Plan p2 = PopulationUtils.createPlan(); p2.setScore(5.0); Plan p3 = PopulationUtils.createPlan(); p3.setScore(11.0); person.addPlan(p1); person.addPlan(p2); person.addPlan(p3); Plan p = new BestPlanSelector<Plan, Person>().selectPlan(person); assertTrue(p == p1 || p == p3); }