use of org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method assertOneChange.
private void assertOneChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, UserPropertyChangeProblemFactChange expected) {
UserPropertyChangeProblemFactChange change = (UserPropertyChangeProblemFactChange) result.get(index);
assertUserEquals(expected.getUser(), change.getUser());
assertEquals(1, result.stream().filter(calculated -> calculated instanceof UserPropertyChangeProblemFactChange).count());
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilder method addUserChanges.
private void addUserChanges(final Map<String, User> usersById, final List<AddUserProblemFactChange> newUserChanges, final List<ProblemFactChange<TaskAssigningSolution>> updateUserChanges) {
final Set<String> updatedUserIds = new HashSet<>();
filterDuplicates(externalUserList).filter(externalUser -> !IS_PLANNING_USER.test(externalUser.getId())).map(UserUtil::fromExternalUser).forEach(user -> {
final User previousUser = usersById.get(user.getEntityId());
updatedUserIds.add(user.getEntityId());
if (previousUser == null) {
newUserChanges.add(new AddUserProblemFactChange(user));
} else if (!equalsByProperties(previousUser, user)) {
updateUserChanges.add(new UserPropertyChangeProblemFactChange(previousUser, true, user.getAttributes(), user.getAllLabelValues(), user.getGroups()));
}
});
usersById.values().stream().filter(user -> !IS_PLANNING_USER.test(user.getEntityId())).filter(user -> !updatedUserIds.contains(user.getEntityId())).filter(User::isEnabled).forEach(user -> updateUserChanges.add(new DisableUserProblemFactChange(user)));
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method addUserPropertyChange.
private void addUserPropertyChange(User currentUser, org.kie.server.services.taskassigning.user.system.api.User externalUser, boolean shouldHaveChanged) {
List<User> userList = mockUserList(currentUser, mockUser("anotherUser"), mockUser("anotherUser1"));
org.kie.server.services.taskassigning.user.system.api.User externalUserRepeated1 = mockExternalUser(externalUser.getId());
org.kie.server.services.taskassigning.user.system.api.User newExternalUserRepeated2 = mockExternalUser(externalUser.getId());
List<org.kie.server.services.taskassigning.user.system.api.User> externalUserList = mockExternalUserList(externalUser, externalUserRepeated1, newExternalUserRepeated2);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), userList);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(Collections.emptyList()).withUserSystem(userSystemService).withUsersUpdate(externalUserList).withContext(context).build();
User fromExternalUser = fromExternalUser(externalUser);
UserPropertyChangeProblemFactChange expected = new UserPropertyChangeProblemFactChange(currentUser, fromExternalUser.isEnabled(), fromExternalUser.getAttributes(), fromExternalUser.getAllLabelValues(), fromExternalUser.getGroups());
if (shouldHaveChanged) {
assertChangeIsTheChangeSetId(result, 0);
assertOneChange(result, 1, expected);
UserPropertyChangeProblemFactChange createdChange = (UserPropertyChangeProblemFactChange) result.get(1);
assertEquals(expected.getUser().getEntityId(), createdChange.getUser().getEntityId());
assertEquals(expected.isEnabled(), createdChange.isEnabled());
assertEquals(expected.getAttributes(), createdChange.getAttributes());
assertEquals(expected.getGroups(), createdChange.getGroups());
assertEquals(expected.getLabelValues(), createdChange.getLabelValues());
} else {
assertNoChange(result, UserPropertyChangeProblemFactChange.class);
}
}
Aggregations