Search in sources :

Example 1 with OrganizationalEntity

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()));
}
Also used : Arrays(java.util.Arrays) Group(org.kie.server.services.taskassigning.core.model.Group) Assert.assertNotNull(org.junit.Assert.assertNotNull) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) TaskData(org.kie.server.api.model.taskassigning.TaskData) HashSet(java.util.HashSet) User(org.kie.server.services.taskassigning.core.model.User) Map(java.util.Map) AFFINITIES(org.kie.server.services.taskassigning.core.model.DefaultLabels.AFFINITIES) Collections(java.util.Collections) UserType(org.kie.server.api.model.taskassigning.UserType) OrganizationalEntity(org.kie.server.api.model.taskassigning.OrganizationalEntity) Assert.assertEquals(org.junit.Assert.assertEquals) SKILLS(org.kie.server.services.taskassigning.core.model.DefaultLabels.SKILLS) Task(org.kie.server.services.taskassigning.core.model.Task) Group(org.kie.server.services.taskassigning.core.model.Group) Task(org.kie.server.services.taskassigning.core.model.Task) User(org.kie.server.services.taskassigning.core.model.User) OrganizationalEntity(org.kie.server.api.model.taskassigning.OrganizationalEntity) HashSet(java.util.HashSet) TaskData(org.kie.server.api.model.taskassigning.TaskData)

Example 2 with OrganizationalEntity

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);
}
Also used : OrganizationalEntity(org.kie.server.api.model.taskassigning.OrganizationalEntity) TaskData(org.kie.server.api.model.taskassigning.TaskData) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 OrganizationalEntity (org.kie.server.api.model.taskassigning.OrganizationalEntity)2 TaskData (org.kie.server.api.model.taskassigning.TaskData)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Test (org.junit.Test)1 UserType (org.kie.server.api.model.taskassigning.UserType)1 AFFINITIES (org.kie.server.services.taskassigning.core.model.DefaultLabels.AFFINITIES)1 SKILLS (org.kie.server.services.taskassigning.core.model.DefaultLabels.SKILLS)1 Group (org.kie.server.services.taskassigning.core.model.Group)1 Task (org.kie.server.services.taskassigning.core.model.Task)1 User (org.kie.server.services.taskassigning.core.model.User)1