@Test void change_vehicle_capacity() { int oldCapacity = 100; int newCapacity = 50; PlanningVehicle workingVehicle = PlanningVehicleFactory.testVehicle(1, oldCapacity); PlanningVehicle changeVehicle = PlanningVehicleFactory.testVehicle(2, newCapacity); when(scoreDirector.lookUpWorkingObject(changeVehicle)).thenReturn(workingVehicle); ChangeVehicleCapacity changeVehicleCapacity = new ChangeVehicleCapacity(changeVehicle); changeVehicleCapacity.doChange(scoreDirector); assertThat(workingVehicle.getCapacity()).isEqualTo(newCapacity); verify(scoreDirector).beforeProblemPropertyChanged(workingVehicle); verify(scoreDirector).afterProblemPropertyChanged(workingVehicle); verify(scoreDirector).triggerVariableListeners(); }
@Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle); if (workingVehicle == null) { throw new IllegalStateException("Can't look up a working copy of " + vehicle); } scoreDirector.beforeProblemPropertyChanged(workingVehicle); workingVehicle.setCapacity(vehicle.getCapacity()); scoreDirector.afterProblemPropertyChanged(workingVehicle); scoreDirector.triggerVariableListeners(); }
ChangeVehicleCapacity implements ProblemFactChange<VehicleRoutingSolution> { @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle); if (workingVehicle == null) { throw new IllegalStateException("Can't look up a working copy of " + vehicle); } scoreDirector.beforeProblemPropertyChanged(workingVehicle); workingVehicle.setCapacity(vehicle.getCapacity()); scoreDirector.afterProblemPropertyChanged(workingVehicle); scoreDirector.triggerVariableListeners(); } }
ChangeVehicleCapacity implements ProblemFactChange<VehicleRoutingSolution> { @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle); if (workingVehicle == null) { throw new IllegalStateException("Can't look up a working copy of " + vehicle); } scoreDirector.beforeProblemPropertyChanged(workingVehicle); workingVehicle.setCapacity(vehicle.getCapacity()); scoreDirector.afterProblemPropertyChanged(workingVehicle); scoreDirector.triggerVariableListeners(); } ChangeVehicleCapacity(PlanningVehicle vehicle); }
ChangeVehicleCapacity implements ProblemFactChange<VehicleRoutingSolution> { @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle); if (workingVehicle == null) { throw new IllegalStateException("Can't look up a working copy of " + vehicle); } scoreDirector.beforeProblemPropertyChanged(workingVehicle); workingVehicle.setCapacity(vehicle.getCapacity()); scoreDirector.afterProblemPropertyChanged(workingVehicle); scoreDirector.triggerVariableListeners(); } ChangeVehicleCapacity(PlanningVehicle vehicle); @Override void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector); }
ChangeVehicleCapacity implements ProblemFactChange<VehicleRoutingSolution> { @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) { PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle); if (workingVehicle == null) { throw new IllegalStateException("Can't look up a working copy of " + vehicle); } scoreDirector.beforeProblemPropertyChanged(workingVehicle); workingVehicle.setCapacity(vehicle.getCapacity()); scoreDirector.afterProblemPropertyChanged(workingVehicle); scoreDirector.triggerVariableListeners(); } ChangeVehicleCapacity(PlanningVehicle vehicle); @Override void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector);  }