Search in sources :

Example 6 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class HumanTaskHandlerHelperTest method testSetDeadlinesNotCompletedReassignWithGroups.

// JBPM-4291
@Test
public void testSetDeadlinesNotCompletedReassignWithGroups() {
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter("NotCompletedReassign", "[users:john|groups:sales]@[4h]");
    @SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
    assertNotNull(deadlines);
    assertEquals(1, deadlines.getEndDeadlines().size());
    assertEquals(0, deadlines.getStartDeadlines().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().size());
    assertEquals(0, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getNotifications().size());
    // verify reassignment
    Reassignment reassignment = deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().get(0);
    assertEquals(2, reassignment.getPotentialOwners().size());
    assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
    assertEquals("sales", reassignment.getPotentialOwners().get(1).getId());
    // check deadline expiration time
    assertNotNull(deadlines.getEndDeadlines().get(0).getDate());
    long expirationTime = deadlines.getEndDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
    assertEquals(4, roundExpirationTime(expirationTime));
}
Also used : Deadlines(org.kie.internal.task.api.model.Deadlines) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) Reassignment(org.kie.internal.task.api.model.Reassignment) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 7 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class HumanTaskHandlerHelperTest method testSetDeadlinesNotCompletedReassignTwoTimes.

@Test
public void testSetDeadlinesNotCompletedReassignTwoTimes() {
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter("NotCompletedReassign", "[users:john]@[4h,6h]");
    @SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
    assertNotNull(deadlines);
    assertEquals(2, deadlines.getEndDeadlines().size());
    assertEquals(0, deadlines.getStartDeadlines().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().size());
    assertEquals(0, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getNotifications().size());
    assertEquals(1, deadlines.getEndDeadlines().get(1).getEscalations().size());
    assertEquals(1, deadlines.getEndDeadlines().get(1).getEscalations().get(0).getReassignments().size());
    assertEquals(0, deadlines.getEndDeadlines().get(1).getEscalations().get(0).getNotifications().size());
    // verify reassignment
    Reassignment reassignment = deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().get(0);
    assertEquals(1, reassignment.getPotentialOwners().size());
    assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
    // check deadline expiration time
    assertNotNull(deadlines.getEndDeadlines().get(0).getDate());
    long expirationTime = deadlines.getEndDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
    assertEquals(4, roundExpirationTime(expirationTime));
    // verify reassignment
    reassignment = deadlines.getEndDeadlines().get(1).getEscalations().get(0).getReassignments().get(0);
    assertEquals(1, reassignment.getPotentialOwners().size());
    assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
    // check deadline expiration time
    assertNotNull(deadlines.getEndDeadlines().get(1).getDate());
    expirationTime = deadlines.getEndDeadlines().get(1).getDate().getTime() - System.currentTimeMillis();
    assertEquals(6, roundExpirationTime(expirationTime));
}
Also used : Deadlines(org.kie.internal.task.api.model.Deadlines) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) Reassignment(org.kie.internal.task.api.model.Reassignment) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 8 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class HumanTaskHandlerHelperTest method testSetDeadlinesNotCompletedReassign.

@Test
public void testSetDeadlinesNotCompletedReassign() {
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter("NotCompletedReassign", "[users:john]@[4h]");
    @SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
    assertNotNull(deadlines);
    assertEquals(1, deadlines.getEndDeadlines().size());
    assertEquals(0, deadlines.getStartDeadlines().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().size());
    assertEquals(1, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().size());
    assertEquals(0, deadlines.getEndDeadlines().get(0).getEscalations().get(0).getNotifications().size());
    // verify reassignment
    Reassignment reassignment = deadlines.getEndDeadlines().get(0).getEscalations().get(0).getReassignments().get(0);
    assertEquals(1, reassignment.getPotentialOwners().size());
    assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
    // check deadline expiration time
    assertNotNull(deadlines.getEndDeadlines().get(0).getDate());
    long expirationTime = deadlines.getEndDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
    assertEquals(4, roundExpirationTime(expirationTime));
}
Also used : Deadlines(org.kie.internal.task.api.model.Deadlines) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) Reassignment(org.kie.internal.task.api.model.Reassignment) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 9 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class HumanTaskHandlerHelperTest method testSetDeadlinesNotStartedReassign.

@Test
public void testSetDeadlinesNotStartedReassign() {
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter("NotStartedReassign", "[users:john]@[4h]");
    @SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
    assertNotNull(deadlines);
    assertEquals(1, deadlines.getStartDeadlines().size());
    assertEquals(0, deadlines.getEndDeadlines().size());
    assertEquals(1, deadlines.getStartDeadlines().get(0).getEscalations().size());
    assertEquals(1, deadlines.getStartDeadlines().get(0).getEscalations().get(0).getReassignments().size());
    assertEquals(0, deadlines.getStartDeadlines().get(0).getEscalations().get(0).getNotifications().size());
    // verify reassignment
    Reassignment reassignment = deadlines.getStartDeadlines().get(0).getEscalations().get(0).getReassignments().get(0);
    assertEquals(1, reassignment.getPotentialOwners().size());
    assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
    // check deadline expiration time
    assertNotNull(deadlines.getStartDeadlines().get(0).getDate());
    long expirationTime = deadlines.getStartDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
    assertEquals(4, roundExpirationTime(expirationTime));
}
Also used : Deadlines(org.kie.internal.task.api.model.Deadlines) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) Reassignment(org.kie.internal.task.api.model.Reassignment) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 10 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class HumanTaskHandlerHelper method parseReassignment.

protected static List<Reassignment> parseReassignment(String reassignString) {
    List<Reassignment> reassignments = new ArrayList<Reassignment>();
    Map<String, String> parameters = asMap(reassignString);
    if (parameters.containsKey("users") || parameters.containsKey("groups")) {
        Reassignment reassignment = TaskModelProvider.getFactory().newReassignment();
        List<OrganizationalEntity> reassignmentUsers = new ArrayList<OrganizationalEntity>();
        String recipients = parameters.get("users");
        if (recipients != null && recipients.trim().length() > 0) {
            String[] recipientsIds = recipients.split(ATTRIBUTES_ELEMENTS_SEPARATOR);
            for (String id : recipientsIds) {
                User user = TaskModelProvider.getFactory().newUser();
                ((InternalOrganizationalEntity) user).setId(id.trim());
                reassignmentUsers.add(user);
            }
        }
        recipients = parameters.get("groups");
        if (recipients != null && recipients.trim().length() > 0) {
            String[] recipientsIds = recipients.split(ATTRIBUTES_ELEMENTS_SEPARATOR);
            for (String id : recipientsIds) {
                Group group = TaskModelProvider.getFactory().newGroup();
                ((InternalOrganizationalEntity) group).setId(id.trim());
                reassignmentUsers.add(group);
            }
        }
        reassignment.setPotentialOwners(reassignmentUsers);
        reassignments.add(reassignment);
    }
    return reassignments;
}
Also used : Group(org.kie.api.task.model.Group) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) ArrayList(java.util.ArrayList) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) Reassignment(org.kie.internal.task.api.model.Reassignment)

Aggregations

Reassignment (org.kie.internal.task.api.model.Reassignment)12 Deadlines (org.kie.internal.task.api.model.Deadlines)7 WorkItem (org.drools.core.process.instance.WorkItem)6 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)3 Deadline (org.kie.internal.task.api.model.Deadline)3 Escalation (org.kie.internal.task.api.model.Escalation)3 TaskReassignment (org.jbpm.services.api.admin.TaskReassignment)2 Group (org.kie.api.task.model.Group)2 Task (org.kie.api.task.model.Task)2 User (org.kie.api.task.model.User)2 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)2 Notification (org.kie.internal.task.api.model.Notification)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1