### Question:
DisableUserProblemFactChange implements ProblemFactChange<TaskAssigningSolution> { @Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(false); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); } DisableUserProblemFactChange(User user); User getUser(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector);  }### Answer:
@Test public void doChange() { List<Task> workingUserTasks = Arrays.asList(mockTask(TASK_ID1, true), mockTask(TASK_ID2, true), mockTask(TASK_ID3, false), mockTask(TASK_ID4, false)); User workingUser = mockUser(USER_ID, workingUserTasks); workingUser.setEnabled(true); when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(workingUser); change.doChange(scoreDirector); verify(scoreDirector).beforeProblemPropertyChanged(workingUser); verify(scoreDirector).afterProblemPropertyChanged(workingUser); verify(scoreDirector).triggerVariableListeners(); assertThat(workingUser.isEnabled()).isFalse(); List<Task> pinnedTasks = Arrays.asList(workingUserTasks.get(0), workingUserTasks.get(1)); for (Task pinnedTask : pinnedTasks) { assertThat(pinnedTask.isPinned()).isTrue(); assertTaskWasNotReleased(pinnedTask, scoreDirector); } List<Task> releasedTasks = Arrays.asList(workingUserTasks.get(2), workingUserTasks.get(3)); releasedTasks.forEach(releasedTask -> assertTaskWasReleased(releasedTask, scoreDirector)); }
@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()).triggerVariableListeners(); }