@Test void fail_fast_if_working_object_is_null() { ChangeVehicleCapacity changeVehicleCapacity = new ChangeVehicleCapacity(PlanningVehicleFactory.testVehicle(1)); assertThatIllegalStateException() .isThrownBy(() -> changeVehicleCapacity.doChange(scoreDirector)) .withMessageContaining("working copy of"); }
@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);  }