/** * @author cdobler */ public void testReplaceLeg() { Plan plan = createSamplePlan(); Leg oldLeg = (Leg)plan.getPlanElements().get(1); Leg newLeg = PopulationUtils.createLeg(TransportMode.walk); // expect rpe to return false if the plan or one of the legs is null assertEquals( WithinDayAgentUtils.replaceLegBlindly(null, oldLeg, newLeg), false); assertEquals( WithinDayAgentUtils.replaceLegBlindly(plan, null, newLeg), false); assertEquals( WithinDayAgentUtils.replaceLegBlindly(plan, oldLeg, null), false); // old leg has to be part of the plan assertEquals( WithinDayAgentUtils.replaceLegBlindly(plan, newLeg, newLeg), false); // replace leg successful assertEquals( WithinDayAgentUtils.replaceLegBlindly(plan, oldLeg, newLeg), true); // check whether leg has really be replaced assertEquals(plan.getPlanElements().get(1).equals(newLeg), true); }