use of org.kie.internal.task.api.model.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testSetDeadlinesNotStartedReassignTwoTimes.
@Test
public void testSetDeadlinesNotStartedReassignTwoTimes() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedReassign", "[users:john]@[4h,6h]");
@SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
assertNotNull(deadlines);
assertEquals(2, 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());
assertEquals(1, deadlines.getStartDeadlines().get(1).getEscalations().size());
assertEquals(1, deadlines.getStartDeadlines().get(1).getEscalations().get(0).getReassignments().size());
assertEquals(0, deadlines.getStartDeadlines().get(1).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));
// verify reassignment
reassignment = deadlines.getStartDeadlines().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.getStartDeadlines().get(1).getDate());
expirationTime = deadlines.getStartDeadlines().get(1).getDate().getTime() - System.currentTimeMillis();
assertEquals(6, roundExpirationTime(expirationTime));
}
use of org.kie.internal.task.api.model.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testNotStartedNotifyMinimalMultipleExpirations.
@Test
public void testNotStartedNotifyMinimalMultipleExpirations() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedNotify", "[tousers:john|subject:Test of notification|body:And here is the body]@[4h,6h]");
@SuppressWarnings("unchecked") Deadlines deadlines = HumanTaskHandlerHelper.setDeadlines(workItem, Collections.EMPTY_LIST, null);
assertNotNull(deadlines);
assertEquals(2, 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).getNotifications().size());
assertEquals(0, deadlines.getStartDeadlines().get(0).getEscalations().get(0).getReassignments().size());
// verify notification
Notification notification = deadlines.getStartDeadlines().get(0).getEscalations().get(0).getNotifications().get(0);
assertNotNull(notification);
assertEquals(1, notification.getRecipients().size());
assertEquals("john", notification.getRecipients().get(0).getId());
assertEquals(1, notification.getSubjects().size());
assertEquals("Test of notification", notification.getSubjects().get(0).getText());
EmailNotification emailNotification = (EmailNotification) notification;
assertEquals(1, emailNotification.getEmailHeaders().size());
Language lang = TaskModelProvider.getFactory().newLanguage();
lang.setMapkey("en-UK");
EmailNotificationHeader header = emailNotification.getEmailHeaders().get(lang);
assertNotNull(header);
assertEquals("Test of notification", header.getSubject());
assertEquals("And here is the body", header.getBody());
// check deadline expiration time
assertNotNull(deadlines.getStartDeadlines().get(0).getDate());
long expirationTime = deadlines.getStartDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
assertEquals(4, roundExpirationTime(expirationTime));
// verify notification
notification = deadlines.getStartDeadlines().get(1).getEscalations().get(0).getNotifications().get(0);
assertNotNull(notification);
assertEquals(1, notification.getRecipients().size());
assertEquals("john", notification.getRecipients().get(0).getId());
assertEquals(1, notification.getSubjects().size());
assertEquals("Test of notification", notification.getSubjects().get(0).getText());
emailNotification = (EmailNotification) notification;
assertEquals(1, emailNotification.getEmailHeaders().size());
lang = TaskModelProvider.getFactory().newLanguage();
lang.setMapkey("en-UK");
header = emailNotification.getEmailHeaders().get(lang);
assertNotNull(header);
assertEquals("Test of notification", header.getSubject());
assertEquals("And here is the body", header.getBody());
// check deadline expiration time
assertNotNull(deadlines.getStartDeadlines().get(1).getDate());
expirationTime = deadlines.getStartDeadlines().get(1).getDate().getTime() - System.currentTimeMillis();
assertEquals(6, roundExpirationTime(expirationTime));
}
use of org.kie.internal.task.api.model.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testSetDeadlinesNotStartedReassignWithGroups.
@Test
public void testSetDeadlinesNotStartedReassignWithGroups() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedReassign", "[users:john|groups:sales]@[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(2, reassignment.getPotentialOwners().size());
assertEquals("john", reassignment.getPotentialOwners().get(0).getId());
assertEquals("sales", reassignment.getPotentialOwners().get(1).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.Deadlines in project jbpm by kiegroup.
the class AddTaskCommand method scheduleDeadlinesForTask.
private void scheduleDeadlinesForTask(final InternalTask task, TaskDeadlinesService deadlineService) {
final long now = System.currentTimeMillis();
Deadlines deadlines = task.getDeadlines();
if (deadlines != null) {
final List<? extends Deadline> startDeadlines = deadlines.getStartDeadlines();
if (startDeadlines != null) {
scheduleDeadlines(startDeadlines, now, task.getId(), DeadlineType.START, deadlineService);
}
final List<? extends Deadline> endDeadlines = deadlines.getEndDeadlines();
if (endDeadlines != null) {
scheduleDeadlines(endDeadlines, now, task.getId(), DeadlineType.END, deadlineService);
}
}
}
use of org.kie.internal.task.api.model.Deadlines 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));
}
Aggregations