@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.setGroups(new HashSet<>()); workingUser.setAttributes(new HashMap<>()); workingUser.setAllLabelValues(new HashMap<>()); 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()).isEqualTo(newEnabled); assertThat(workingUser.getGroups()).isEqualTo(newGroups); assertThat(workingUser.getAllLabelValues()).isEqualTo(newLabelValues); assertThat(workingUser.getAttributes()).isEqualTo(newAttributes); 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)); }
@Override public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) { final User workingUser = scoreDirector.lookUpWorkingObjectOrReturnNull(user); if (workingUser == null) { return; } scoreDirector.beforeProblemPropertyChanged(workingUser); workingUser.setEnabled(enabled); workingUser.setAllLabelValues(labelValues); workingUser.setAttributes(attributes); workingUser.setGroups(groups); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); }
UserPropertyChangeProblemFactChange 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(enabled); workingUser.setAllLabelValues(labelValues); workingUser.setAttributes(attributes); workingUser.setGroups(groups); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); } }
UserPropertyChangeProblemFactChange 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(enabled); workingUser.setAllLabelValues(labelValues); workingUser.setAttributes(attributes); workingUser.setGroups(groups); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); } UserPropertyChangeProblemFactChange(User user, boolean enabled, Map<String, Object> attributes,
                                               Map<String, Set<Object>> labelValues, Set<Group> groups); }
UserPropertyChangeProblemFactChange 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(enabled); workingUser.setAllLabelValues(labelValues); workingUser.setAttributes(attributes); workingUser.setGroups(groups); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); } UserPropertyChangeProblemFactChange(User user, boolean enabled, Map<String, Object> attributes,
                                               Map<String, Set<Object>> labelValues, Set<Group> groups); User getUser(); boolean isEnabled(); Map<String, Object> getAttributes(); Map<String, Set<Object>> getLabelValues(); Set<Group> getGroups(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector); }
UserPropertyChangeProblemFactChange 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(enabled); workingUser.setAllLabelValues(labelValues); workingUser.setAttributes(attributes); workingUser.setGroups(groups); scoreDirector.afterProblemPropertyChanged(workingUser); releaseNonPinnedTasks(workingUser, scoreDirector); scoreDirector.triggerVariableListeners(); } UserPropertyChangeProblemFactChange(User user, boolean enabled, Map<String, Object> attributes,
                                               Map<String, Set<Object>> labelValues, Set<Group> groups); User getUser(); boolean isEnabled(); Map<String, Object> getAttributes(); Map<String, Set<Object>> getLabelValues(); Set<Group> getGroups(); @Override void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector);  }