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));
}
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));
}
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));
}
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));
}
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;
}
Aggregations