use of org.kie.server.api.model.taskassigning.OrganizationalEntity 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.api.model.taskassigning.OrganizationalEntity in project droolsjbpm-integration by kiegroup.
the class TaskAssigningTaskDataWithPotentialOwnersQueryMapperTest method assertTaskIsPresent.
protected void assertTaskIsPresent(List<TaskData> taskDataList, int index, Long taskId, Date createdOn, String actualOwner, String deploymentId, String taskName, Integer priority, String processId, Long processInstanceId, String status, Date lastModificationDate, PlanningTask planningTask, List<Pair<String, String>> potentialOwners) {
TaskData taskData = taskDataList.get(index);
Set<OrganizationalEntity> potentialOwnersSet = new HashSet<>();
potentialOwners.forEach(potentialOwner -> potentialOwnersSet.add(OrganizationalEntity.builder().name(potentialOwner.getLeft()).type(potentialOwner.getRight()).build()));
TaskData expectedTaskData = TaskData.builder().taskId(taskId).createdOn(createdOn != null ? LocalDateTime.ofInstant(createdOn.toInstant(), ZoneId.systemDefault()) : null).actualOwner(actualOwner).containerId(deploymentId).name(taskName).priority(priority).processId(processId).processInstanceId(processInstanceId).status(status).lastModificationDate(lastModificationDate != null ? LocalDateTime.ofInstant(lastModificationDate.toInstant(), ZoneId.systemDefault()) : null).planningTask(planningTask).potentialOwners(potentialOwnersSet).build();
assertNotNull(taskData);
assertEquals(expectedTaskData, taskData);
}
Aggregations