use of org.kie.kogito.taskassigning.core.model.solver.realtime.AddUserProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addNewUserChange.
@Test
void addNewUserChange() {
org.kie.kogito.taskassigning.user.service.User newExternalUser = mockExternalUser(USER_1);
User newUser = mockUser(USER_1);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), Collections.emptyList());
UserDataEvent event = new UserDataEvent(Collections.singletonList(newExternalUser), ZonedDateTime.now());
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(Collections.emptyList()).fromUserDataEvent(event).forSolution(solution).build();
AddUserProblemFactChange expected = new AddUserProblemFactChange(newUser);
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertThatUserProcessorsWereApplied(newExternalUser);
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.AddUserProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method assertChange.
private static void assertChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, AddUserProblemFactChange expected) {
assertThat(result.get(index)).isInstanceOf(AddUserProblemFactChange.class);
AddUserProblemFactChange change = (AddUserProblemFactChange) result.get(index);
assertUserEquals(change.getUser(), expected.getUser());
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.AddUserProblemFactChange 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)));
}
Aggregations