@Test public void doChange() { change.doChange(scoreDirector); verify(scoreDirector).beforeProblemFactAdded(user); verify(scoreDirector).afterProblemFactAdded(user); verify(scoreDirector).triggerVariableListeners(); assertThat(workingSolution.getUserList()).contains(user); }
@Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser != null) { throw new TaskAssigningRuntimeException(String.format("A user with the given identifier id: %s already exists", user.getEntityId())); } workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactAdded(user); workingSolution.getUserList().add(user); scoreDirector.afterProblemFactAdded(user); scoreDirector.triggerVariableListeners(); }
AddUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser != null) { throw new TaskAssigningRuntimeException(String.format("A user with the given identifier id: %s already exists", user.getEntityId())); } workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactAdded(user); workingSolution.getUserList().add(user); scoreDirector.afterProblemFactAdded(user); scoreDirector.triggerVariableListeners(); } }
AddUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser != null) { throw new TaskAssigningRuntimeException(String.format("A user with the given identifier id: %s already exists", user.getEntityId())); } workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactAdded(user); workingSolution.getUserList().add(user); scoreDirector.afterProblemFactAdded(user); scoreDirector.triggerVariableListeners(); } AddUserProblemFactChange(User user); }
AddUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser != null) { throw new TaskAssigningRuntimeException(String.format("A user with the given identifier id: %s already exists", user.getEntityId())); } workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactAdded(user); workingSolution.getUserList().add(user); scoreDirector.afterProblemFactAdded(user); scoreDirector.triggerVariableListeners(); } AddUserProblemFactChange(User user); User getUser(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector); }
AddUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser != null) { throw new TaskAssigningRuntimeException(String.format("A user with the given identifier id: %s already exists", user.getEntityId())); } workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactAdded(user); workingSolution.getUserList().add(user); scoreDirector.afterProblemFactAdded(user); scoreDirector.triggerVariableListeners(); } AddUserProblemFactChange(User user); User getUser(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector);  }