use of org.kie.api.task.model.OrganizationalEntity in project jbpm by kiegroup.
the class EmailNotificationPublisherTest method testEmailNotificationWithoutTemplateToGroup.
@Test
public void testEmailNotificationWithoutTemplateToGroup() throws Exception {
EmailNotificationPublisher publisher = new EmailNotificationPublisher(connection, userInfo);
Set<OrganizationalEntity> recipients = new HashSet<>(Arrays.asList(factory.newGroup("managers")));
publisher.publish("admin@jbpm.org", "Test notification", recipients, "Test body");
assertEquals(1, wiser.getMessages().size());
MimeMessage msg = ((WiserMessage) wiser.getMessages().get(0)).getMimeMessage();
// Side effect of MIME encoding (I think.. ): \r\n..
String content = ((String) msg.getContent()).replace("\r\n", "");
assertEquals("Test body", content);
assertEquals("Test notification", msg.getSubject());
assertEquals("admin@jbpm.org", ((InternetAddress) msg.getFrom()[0]).getAddress());
assertEquals("john@domain.com", ((InternetAddress) msg.getRecipients(RecipientType.TO)[0]).getAddress());
assertNull(msg.getRecipients(RecipientType.CC));
assertNull(msg.getRecipients(RecipientType.BCC));
}
use of org.kie.api.task.model.OrganizationalEntity in project jbpm by kiegroup.
the class EmailNotificationPublisherTest method testEmailNotificationWithoutTemplateToMultipleRecipients.
@Test
public void testEmailNotificationWithoutTemplateToMultipleRecipients() throws Exception {
EmailNotificationPublisher publisher = new EmailNotificationPublisher(connection, userInfo);
Set<OrganizationalEntity> recipients = new LinkedHashSet<>(Arrays.asList(factory.newGroup("managers"), factory.newUser("mary")));
publisher.publish("admin@jbpm.org", "Test notification", recipients, "Test body");
assertEquals(2, wiser.getMessages().size());
MimeMessage msg = ((WiserMessage) wiser.getMessages().get(0)).getMimeMessage();
// Side effect of MIME encoding (I think.. ): \r\n..
String content = ((String) msg.getContent()).replace("\r\n", "");
assertEquals("Test body", content);
assertEquals("Test notification", msg.getSubject());
assertEquals("admin@jbpm.org", ((InternetAddress) msg.getFrom()[0]).getAddress());
assertEquals("john@domain.com", ((InternetAddress) msg.getRecipients(RecipientType.TO)[0]).getAddress());
assertNull(msg.getRecipients(RecipientType.CC));
assertNull(msg.getRecipients(RecipientType.BCC));
}
use of org.kie.api.task.model.OrganizationalEntity in project jbpm by kiegroup.
the class LifeCycleBaseTest method testNominateToUser.
@Test
public void testNominateToUser() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { businessAdministrators = [ new User('Darth Vader'), new User('Bobba Fet') ] } ),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>(1);
User user = createUser("Jabba Hutt");
potentialOwners.add(user);
taskService.nominate(taskId, "Darth Vader", potentialOwners);
// shouldn't affect the assignments
Task task1 = taskService.getTaskById(taskId);
assertEquals(task1.getTaskData().getActualOwner().getId(), "Jabba Hutt");
assertEquals(task1.getTaskData().getStatus(), Status.Reserved);
}
use of org.kie.api.task.model.OrganizationalEntity in project jbpm by kiegroup.
the class LifeCycleBaseTest method testCompleteWithRestrictedGroups.
@Test
public void testCompleteWithRestrictedGroups() {
// One potential owner, should go straight to state Reserved
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new Group('analyst'), new Group('Crusaders') ],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<OrganizationalEntity> potOwners = task.getPeopleAssignments().getPotentialOwners();
assertNotNull(potOwners);
assertEquals(1, potOwners.size());
assertEquals("Crusaders", potOwners.get(0).getId());
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
// Check is Complete
taskService.complete(taskId, "Darth Vader", null);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Completed, task2.getTaskData().getStatus());
assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
}
use of org.kie.api.task.model.OrganizationalEntity in project jbpm by kiegroup.
the class LifeCycleBaseTest method testActivateFromIncorrectStatus.
@Test
public void testActivateFromIncorrectStatus() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { status = Status.Ready } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [ new User('Darth Vader'), new User('Bobba Fet') ], ";
str += "businessAdministrators = [ new User('Jabba Hutt') ] } ),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str), null);
// We need to add the Admin if we don't initialize the task
if (task.getPeopleAssignments() != null && task.getPeopleAssignments().getBusinessAdministrators() != null) {
List<OrganizationalEntity> businessAdmins = new ArrayList<OrganizationalEntity>();
User user = createUser("Administrator");
businessAdmins.add(user);
businessAdmins.addAll(task.getPeopleAssignments().getBusinessAdministrators());
((InternalPeopleAssignments) task.getPeopleAssignments()).setBusinessAdministrators(businessAdmins);
}
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
try {
taskService.activate(taskId, "Darth Vader");
fail("Shouldn't have succeded");
} catch (RuntimeException e) {
// assertNotNull(activateResponseHandler.getError());
// assertNotNull(activateResponseHandler.getError().getMessage());
// assertTrue(activateResponseHandler.getError().getMessage().contains("Darth Vader"));
}
}
Aggregations