use of org.kie.kogito.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addDisableUserChange.
@Test
void addDisableUserChange() {
User user = mockUser(USER_1);
user.setEnabled(true);
TaskAssigningSolution solution = mockSolution(Collections.singletonList(user), Collections.emptyList());
UserDataEvent event = new UserDataEvent(Collections.emptyList(), ZonedDateTime.now());
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(Collections.emptyList()).fromUserDataEvent(event).forSolution(solution).build();
DisableUserProblemFactChange expected = new DisableUserProblemFactChange(user);
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertThatUserProcessorsWereNotApplied();
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilder method addFullSyncUserChanges.
private void addFullSyncUserChanges(List<org.kie.kogito.taskassigning.user.service.User> externalUserList) {
final Set<String> updatedUserIds = new HashSet<>();
externalUserList.stream().filter(externalUser -> !IS_PLANNING_USER.test(externalUser.getId())).map(externalUser -> fromExternalUser(externalUser, processorRegistry)).forEach(synchedUser -> {
final User previousUser = usersById.get(synchedUser.getId());
updatedUserIds.add(synchedUser.getId());
if (previousUser == null) {
// add brand new users
newUserChanges.add(new AddUserProblemFactChange(synchedUser));
} else if (!equalsByProperties(previousUser, synchedUser)) {
// update the users that has changes.
updateUserChanges.add(new UserPropertyChangeProblemFactChange(previousUser, true, synchedUser.getAttributes(), synchedUser.getGroups()));
}
});
// current users not present in the synchronization data set are marked for disabling.
usersById.values().stream().filter(previousUser -> !IS_PLANNING_USER.test(previousUser.getId())).filter(previousUser -> !updatedUserIds.contains(previousUser.getId())).filter(User::isEnabled).forEach(previousUser -> updateUserChanges.add(new DisableUserProblemFactChange(previousUser)));
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method assertChange.
private static void assertChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, DisableUserProblemFactChange expected) {
assertThat(result.get(index)).isInstanceOf(DisableUserProblemFactChange.class);
DisableUserProblemFactChange change = (DisableUserProblemFactChange) result.get(index);
assertUserEquals(change.getUser(), expected.getUser());
}
Aggregations