@Test public void doChangeUserDontExists() { when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(null); change.doChange(scoreDirector); verify(scoreDirector, never()).beforeProblemPropertyChanged(any()); verify(scoreDirector, never()).afterProblemPropertyChanged(any()); verify(scoreDirector, never()).beforeProblemFactRemoved(any()); verify(scoreDirector, never()).afterProblemFactRemoved(any()); assertThat(workingSolution.getUserList().size()).isEqualTo(2); assertThat(workingSolution.getUserList()).contains(user2, user3); verify(scoreDirector, never()).triggerVariableListeners(); }
@Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } if (workingUser.isEnabled()) { scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); } releaseAllTasks(workingUser, scoreDirector); workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactRemoved(workingUser); workingSolution.getUserList().remove(workingUser); scoreDirector.afterProblemFactRemoved(workingUser); scoreDirector.triggerVariableListeners(); }
RemoveUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } if (workingUser.isEnabled()) { scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); } releaseAllTasks(workingUser, scoreDirector); workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactRemoved(workingUser); workingSolution.getUserList().remove(workingUser); scoreDirector.afterProblemFactRemoved(workingUser); scoreDirector.triggerVariableListeners(); } }
RemoveUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } if (workingUser.isEnabled()) { scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); } releaseAllTasks(workingUser, scoreDirector); workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactRemoved(workingUser); workingSolution.getUserList().remove(workingUser); scoreDirector.afterProblemFactRemoved(workingUser); scoreDirector.triggerVariableListeners(); } RemoveUserProblemFactChange(User user); }
RemoveUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } if (workingUser.isEnabled()) { scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); } releaseAllTasks(workingUser, scoreDirector); workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactRemoved(workingUser); workingSolution.getUserList().remove(workingUser); scoreDirector.afterProblemFactRemoved(workingUser); scoreDirector.triggerVariableListeners(); } RemoveUserProblemFactChange(User user); User getUser(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector); }
RemoveUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final TaskAssigningSolution workingSolution = scoreDirector.getWorkingSolution(); final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } if (workingUser.isEnabled()) { scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); } releaseAllTasks(workingUser, scoreDirector); workingSolution.setUserList(new ArrayList<>(workingSolution.getUserList())); scoreDirector.beforeProblemFactRemoved(workingUser); workingSolution.getUserList().remove(workingUser); scoreDirector.afterProblemFactRemoved(workingUser); scoreDirector.triggerVariableListeners(); } RemoveUserProblemFactChange(User user); User getUser(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector);  }