AddVisit implements ProblemFactChange<VehicleRoutingSolution> { @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { scoreDirector.beforeEntityAdded(visit); scoreDirector.getWorkingSolution().getVisitList().add(visit); scoreDirector.afterEntityAdded(visit); scoreDirector.triggerVariableListeners(); } AddVisit(PlanningVisit visit); @Override void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector);  }
@Test void add_visit_should_add_location_and_create_visit() { VehicleRoutingSolution solution = SolutionFactory.emptySolution(); when(scoreDirector.getWorkingSolution()).thenReturn(solution); PlanningVisit visit = PlanningVisitFactory.testVisit(1); AddVisit addVisit = new AddVisit(visit); addVisit.doChange(scoreDirector); verify(scoreDirector).beforeEntityAdded(visit); verify(scoreDirector).afterEntityAdded(visit); assertThat(solution.getVisitList()).containsExactly(visit); verify(scoreDirector).triggerVariableListeners(); }