use of org.kie.server.services.taskassigning.core.model.User in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method buildUsersForEqualityCase.
private Pair<User, org.kie.server.services.taskassigning.user.system.api.User> buildUsersForEqualityCase() {
Map<String, Set<Object>> labelValues = new HashMap<>();
labelValues.put(DefaultLabels.SKILLS.name(), Collections.singleton(SKILL1));
labelValues.put(DefaultLabels.AFFINITIES.name(), Collections.emptySet());
Map<String, Object> attributes = new HashMap<>();
attributes.put(SKILLS_ATTRIBUTE_NAME, SKILL1);
attributes.put(ATTRIBUTE1_ID, ATTRIBUTE1_VALUE);
User user1 = mockUser(USER1_ID, true, Collections.singleton(new Group(GROUP1_ID.hashCode(), GROUP1_ID)), attributes, labelValues);
Map<String, Object> externalUserAttributes = new HashMap<>();
externalUserAttributes.put(ATTRIBUTE1_ID, ATTRIBUTE1_VALUE);
externalUserAttributes.put(SKILLS_ATTRIBUTE_NAME, SKILL1);
Set<org.kie.server.services.taskassigning.user.system.api.Group> externalUserGroups = new HashSet<>();
externalUserGroups.add(mockExternalGroup(GROUP1_ID));
org.kie.server.services.taskassigning.user.system.api.User externalUser = mockExternalUser(USER1_ID, externalUserGroups, externalUserAttributes);
return Pair.of(user1, externalUser);
}
use of org.kie.server.services.taskassigning.core.model.User in project droolsjbpm-integration by kiegroup.
the class TaskUtilTest method fromTaskData.
private void fromTaskData(Map<String, Object> inputData, Set<Object> expectedSkills, Set<Object> expectedAffinities) {
Set<OrganizationalEntity> potentialOwners = new HashSet<>();
potentialOwners.add(OE_1);
potentialOwners.add(OE_2);
TaskData taskData = TaskData.builder().taskId(TASK_ID).processInstanceId(PROCESS_INSTANCE_ID).processId(PROCESS_ID).containerId(CONTAINER_ID).name(NAME).priority(PRIORITY).status(STATUS).inputData(inputData).potentialOwners(potentialOwners).build();
Task task = TaskUtil.fromTaskData(taskData);
assertEquals(TASK_ID, task.getId(), 0);
assertEquals(PROCESS_INSTANCE_ID, task.getProcessInstanceId(), 0);
assertEquals(PROCESS_ID, task.getProcessId());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(NAME, task.getName());
assertEquals(PRIORITY, task.getPriority(), 0);
assertEquals(STATUS, task.getStatus());
assertEquals(inputData, task.getInputData());
assertEquals(potentialOwners.size(), task.getPotentialOwners().size(), 2);
User user = task.getPotentialOwners().stream().filter(u -> OE_1.getName().equals(u.getEntityId()) && u.isUser()).map(u -> (User) u).findFirst().orElse(null);
assertNotNull(user);
Group group = task.getPotentialOwners().stream().filter(g -> OE_2.getName().equals(g.getEntityId()) && !g.isUser()).map(g -> (Group) g).findFirst().orElse(null);
assertNotNull(group);
assertEquals(expectedSkills, task.getLabelValues(SKILLS.name()));
assertEquals(expectedAffinities, task.getLabelValues(AFFINITIES.name()));
}
use of org.kie.server.services.taskassigning.core.model.User in project droolsjbpm-integration by kiegroup.
the class RemoveUserProblemFactChangeTest method doChange.
@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_1, workingUserTasks);
workingUser.setEnabled(true);
workingSolution.getUserList().add(workingUser);
int originalUsersSize = workingSolution.getUserList().size();
when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(workingUser);
change.doChange(scoreDirector);
verify(scoreDirector).beforeProblemPropertyChanged(workingUser);
verify(scoreDirector).afterProblemPropertyChanged(workingUser);
verify(scoreDirector).triggerVariableListeners();
assertThat(workingUser.isEnabled()).isFalse();
workingUserTasks.forEach(task -> assertTaskWasReleased(task, scoreDirector));
verify(scoreDirector).beforeProblemFactRemoved(workingUser);
verify(scoreDirector).afterProblemFactRemoved(workingUser);
assertThat(workingSolution.getUserList().size()).isEqualTo(originalUsersSize - 1);
assertThat(workingSolution.getUserList()).contains(user2, user3);
assertThat(workingSolution.getUserList()).doesNotContain(workingUser);
}
use of org.kie.server.services.taskassigning.core.model.User in project droolsjbpm-integration by kiegroup.
the class TaskAssigningGenerator method createUserList.
private void createUserList(TaskAssigningSolution solution, int userListSize, List<Group> groupList) {
List<User> userList = new ArrayList<>(userListSize);
userNameGenerator.predictMaximumSizeAndReset(userListSize);
for (int i = 0; i < userListSize; i++) {
User user = new User();
user.setId((long) i);
String userName = userNameGenerator.generateNextValue();
user.setEntityId(userName);
int groupListSize = USER_GROUP_SET_SIZE_MINIMUM + random.nextInt(USER_GROUP_SET_MAXIMUM - USER_GROUP_SET_SIZE_MINIMUM);
if (groupListSize > groupList.size()) {
groupListSize = groupList.size();
}
Set<Group> groupSet = new LinkedHashSet<>(groupListSize);
int groupListIndex = random.nextInt(groupList.size());
for (int j = 0; j < groupListSize; j++) {
groupSet.add(groupList.get(groupListIndex));
groupListIndex = (groupListIndex + 1) % groupList.size();
}
user.setGroups(groupSet);
logger.trace("Created user with entityId ({}).", userName);
userList.add(user);
}
solution.setUserList(userList);
}
use of org.kie.server.services.taskassigning.core.model.User in project droolsjbpm-integration by kiegroup.
the class TaskAssigningGenerator method createTaskList.
private void createTaskList(TaskAssigningSolution solution, int taskListSize, List<Group> groupList) {
List<User> userList = solution.getUserList();
List<Task> taskList = new ArrayList<>(taskListSize);
for (int i = 0; i < taskListSize; i++) {
Task task = new Task();
task.setId((long) i);
task.setName("Task_" + task.getId());
task.setPriority(random.nextInt(TASK_MAX_PRIORITY + 1));
Set<OrganizationalEntity> potentialOwners = new LinkedHashSet<>();
int groupListIndex = random.nextInt(groupList.size());
int groupPotentialOwnersSize = TASK_POTENTIAL_OWNERS_GROUP_SIZE_MINIMUM + random.nextInt(TASK_POTENTIAL_OWNERS_GROUP_SIZE_MAXIMUM - TASK_POTENTIAL_OWNERS_GROUP_SIZE_MINIMUM);
if (groupPotentialOwnersSize > groupList.size()) {
groupPotentialOwnersSize = groupList.size();
}
for (int j = 0; j < groupPotentialOwnersSize; j++) {
potentialOwners.add(groupList.get(groupListIndex));
groupListIndex = (groupListIndex + 1) % groupList.size();
}
int userListIndex = random.nextInt(userList.size());
int userPotentialOwnersSize = TASK_POTENTIAL_OWNERS_USER_SIZE_MINIMUM + random.nextInt(TASK_POTENTIAL_OWNERS_USER_SIZE_MAXIMUM - TASK_POTENTIAL_OWNERS_USER_SIZE_MINIMUM);
if (userPotentialOwnersSize > userList.size()) {
userPotentialOwnersSize = userList.size();
}
for (int j = 0; j < userPotentialOwnersSize; j++) {
potentialOwners.add(userList.get(userListIndex));
userListIndex = (userListIndex + 1) % userList.size();
}
task.setPotentialOwners(potentialOwners);
taskList.add(task);
}
solution.setTaskList(taskList);
}
Aggregations