@Test public void doChangeFailure() { when(scoreDirector.lookUpWorkingObjectOrReturnNull(task)).thenReturn(null); TaskPropertyChangeProblemFactChange change = new TaskPropertyChangeProblemFactChange(task); Assertions.assertThatThrownBy(() -> change.doChange(scoreDirector)) .hasMessageContaining("was not found in current working solution"); }
@Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { Task workingTask = scoreDirector.lookUpWorkingObjectOrReturnNull(task); if (workingTask == null) { throw new TaskAssigningRuntimeException(String.format("Expected task: %s was not found in current working solution", task)); } if (priority != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setPriority(priority); scoreDirector.afterProblemPropertyChanged(workingTask); } if (status != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setStatus(status); scoreDirector.afterProblemPropertyChanged(workingTask); } scoreDirector.triggerVariableListeners(); }
TaskPropertyChangeProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { Task workingTask = scoreDirector.lookUpWorkingObjectOrReturnNull(task); if (workingTask == null) { throw new TaskAssigningRuntimeException(String.format("Expected task: %s was not found in current working solution", task)); } if (priority != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setPriority(priority); scoreDirector.afterProblemPropertyChanged(workingTask); } if (status != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setStatus(status); scoreDirector.afterProblemPropertyChanged(workingTask); } scoreDirector.triggerVariableListeners(); } }
TaskPropertyChangeProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { Task workingTask = scoreDirector.lookUpWorkingObjectOrReturnNull(task); if (workingTask == null) { throw new TaskAssigningRuntimeException(String.format("Expected task: %s was not found in current working solution", task)); } if (priority != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setPriority(priority); scoreDirector.afterProblemPropertyChanged(workingTask); } if (status != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setStatus(status); scoreDirector.afterProblemPropertyChanged(workingTask); } scoreDirector.triggerVariableListeners(); } TaskPropertyChangeProblemFactChange(Task task); }
TaskPropertyChangeProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { Task workingTask = scoreDirector.lookUpWorkingObjectOrReturnNull(task); if (workingTask == null) { throw new TaskAssigningRuntimeException(String.format("Expected task: %s was not found in current working solution", task)); } if (priority != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setPriority(priority); scoreDirector.afterProblemPropertyChanged(workingTask); } if (status != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setStatus(status); scoreDirector.afterProblemPropertyChanged(workingTask); } scoreDirector.triggerVariableListeners(); } TaskPropertyChangeProblemFactChange(Task task); String getStatus(); void setStatus(String status); Integer getPriority(); void setPriority(Integer priority); Task getTask(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector); }
TaskPropertyChangeProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { Task workingTask = scoreDirector.lookUpWorkingObjectOrReturnNull(task); if (workingTask == null) { throw new TaskAssigningRuntimeException(String.format("Expected task: %s was not found in current working solution", task)); } if (priority != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setPriority(priority); scoreDirector.afterProblemPropertyChanged(workingTask); } if (status != null) { scoreDirector.beforeProblemPropertyChanged(workingTask); workingTask.setStatus(status); scoreDirector.afterProblemPropertyChanged(workingTask); } scoreDirector.triggerVariableListeners(); } TaskPropertyChangeProblemFactChange(Task task); String getStatus(); void setStatus(String status); Integer getPriority(); void setPriority(Integer priority); Task getTask(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector);  }