use of org.kie.internal.task.api.model.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testNotStartedNotifyMinimalWithHtml.
@Test
public void testNotStartedNotifyMinimalWithHtml() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedNotify", "[tousers:john|subject:Test of notification|body:<html>" + "<body>" + "Reason {s}<br/>" + "body of notification:<br/>" + "work item id - ${workItemId}<br/>" + "process instance id - ${processInstanceId}<br/>" + "task id - ${taskId}<br/>" + "http://localhost:8080/taskserver-url" + "expiration time - ${doc['Deadlines'][0].expires}<br/>" + "</body>" + "</html>]@[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).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());
assertTrue((header.getBody().indexOf("http://localhost:8080/taskserver-url") != -1));
// 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 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.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testNotStartedNotifyMinimal.
@Test
public void testNotStartedNotifyMinimal() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedNotify", "[tousers:john|subject:Test of notification|body:And here is the body]@[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).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));
}
use of org.kie.internal.task.api.model.Deadlines 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.Deadlines in project jbpm by kiegroup.
the class HumanTaskHandlerHelperTest method testNotStartedNotifyAllElements.
@Test
public void testNotStartedNotifyAllElements() {
WorkItem workItem = new WorkItemImpl();
workItem.setParameter("NotStartedNotify", "[from:mike|tousers:john,mary|togroups:sales,hr|replyto:mike|subject:Test of notification|body:And here is the body]@[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).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(4, notification.getRecipients().size());
assertEquals("john", notification.getRecipients().get(0).getId());
assertEquals("mary", notification.getRecipients().get(1).getId());
assertEquals("sales", notification.getRecipients().get(2).getId());
assertEquals("hr", notification.getRecipients().get(3).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());
assertEquals("mike", header.getFrom());
assertEquals("mike", header.getReplyTo());
// check deadline expiration time
assertNotNull(deadlines.getStartDeadlines().get(0).getDate());
long expirationTime = deadlines.getStartDeadlines().get(0).getDate().getTime() - System.currentTimeMillis();
assertEquals(4, roundExpirationTime(expirationTime));
}
Aggregations