use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class EmailDeadlinesBaseTest method testDelayedEmailNotificationOnDeadlineTaskCompleted.
@Test(timeout = 10000)
public void testDelayedEmailNotificationOnDeadlineTaskCompleted() throws Exception {
CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(1, false, true);
addCountDownListner(countDownListener);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("now", new Date());
Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
InternalTask task = (InternalTask) TaskFactory.evalTask(reader, vars);
((InternalTaskData) task.getTaskData()).setSkipable(true);
InternalPeopleAssignments assignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
User user = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user).setId("Administrator");
ba.add(user);
assignments.setBusinessAdministrators(ba);
List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
User user2 = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user2).setId("Administrator");
po.add(user2);
assignments.setPotentialOwners(po);
task.setPeopleAssignments(assignments);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
InternalContent content = (InternalContent) TaskModelProvider.getFactory().newContent();
Map<String, String> params = fillMarshalSubjectAndBodyParams();
ContentData marshalledObject = ContentMarshallerHelper.marshal(task, params, null);
content.setContent(marshalledObject.getContent());
taskService.addContent(taskId, content);
long contentId = content.getId();
content = (InternalContent) taskService.getContentById(contentId);
Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
checkContentSubjectAndBody(unmarshallObject);
taskService.start(taskId, "Administrator");
taskService.complete(taskId, "Administrator", null);
// emails should not be set yet
assertEquals(0, getWiser().getMessages().size());
countDownListener.waitTillCompleted();
// no email should ne sent as task was completed before deadline was triggered
assertEquals(0, getWiser().getMessages().size());
task = (InternalTask) taskService.getTaskById(taskId);
assertEquals(Status.Completed, task.getTaskData().getStatus());
assertEquals(0, task.getDeadlines().getStartDeadlines().size());
assertEquals(0, task.getDeadlines().getEndDeadlines().size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class EmailDeadlinesBaseTest method testDelayedEmailNotificationOnDeadlineTaskExited.
@Test(timeout = 10000)
public void testDelayedEmailNotificationOnDeadlineTaskExited() throws Exception {
CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(1, false, true);
addCountDownListner(countDownListener);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("now", new Date());
Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
InternalTask task = (InternalTask) TaskFactory.evalTask(reader, vars);
((InternalTaskData) task.getTaskData()).setSkipable(true);
InternalPeopleAssignments assignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
User user = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user).setId("Administrator");
ba.add(user);
assignments.setBusinessAdministrators(ba);
List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
User user2 = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user2).setId("Administrator");
po.add(user2);
assignments.setPotentialOwners(po);
task.setPeopleAssignments(assignments);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
InternalContent content = (InternalContent) TaskModelProvider.getFactory().newContent();
Map<String, String> params = fillMarshalSubjectAndBodyParams();
ContentData marshalledObject = ContentMarshallerHelper.marshal(task, params, null);
content.setContent(marshalledObject.getContent());
taskService.addContent(taskId, content);
long contentId = content.getId();
content = (InternalContent) taskService.getContentById(contentId);
Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
checkContentSubjectAndBody(unmarshallObject);
taskService.exit(taskId, "Administrator");
// emails should not be set yet
assertEquals(0, getWiser().getMessages().size());
countDownListener.waitTillCompleted();
// no email should ne sent as task was completed before deadline was triggered
assertEquals(0, getWiser().getMessages().size());
task = (InternalTask) taskService.getTaskById(taskId);
assertEquals(Status.Exited, task.getTaskData().getStatus());
assertEquals(0, task.getDeadlines().getStartDeadlines().size());
assertEquals(0, task.getDeadlines().getEndDeadlines().size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class EmailDeadlinesBaseTest method testDelayedEmailNotificationOnDeadlineTaskSkipped.
@Test(timeout = 10000)
public void testDelayedEmailNotificationOnDeadlineTaskSkipped() throws Exception {
CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(1, false, true);
addCountDownListner(countDownListener);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("now", new Date());
Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
InternalTask task = (InternalTask) TaskFactory.evalTask(reader, vars);
((InternalTaskData) task.getTaskData()).setSkipable(true);
InternalPeopleAssignments assignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
User user = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user).setId("Administrator");
ba.add(user);
assignments.setBusinessAdministrators(ba);
List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
User user2 = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user2).setId("Administrator");
po.add(user2);
assignments.setPotentialOwners(po);
task.setPeopleAssignments(assignments);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
InternalContent content = (InternalContent) TaskModelProvider.getFactory().newContent();
Map<String, String> params = fillMarshalSubjectAndBodyParams();
ContentData marshalledObject = ContentMarshallerHelper.marshal(task, params, null);
content.setContent(marshalledObject.getContent());
taskService.addContent(taskId, content);
long contentId = content.getId();
content = (InternalContent) taskService.getContentById(contentId);
Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
checkContentSubjectAndBody(unmarshallObject);
taskService.skip(taskId, "Administrator");
// emails should not be set yet
assertEquals(0, getWiser().getMessages().size());
countDownListener.waitTillCompleted();
// no email should ne sent as task was completed before deadline was triggered
assertEquals(0, getWiser().getMessages().size());
task = (InternalTask) taskService.getTaskById(taskId);
assertEquals(Status.Obsolete, task.getTaskData().getStatus());
assertEquals(0, task.getDeadlines().getStartDeadlines().size());
assertEquals(0, task.getDeadlines().getEndDeadlines().size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class PeopleAssignmentHelperTest method testAssignActors.
@Test
public void testAssignActors() {
String actorId = "espiegelberg";
Task task = TaskModelProvider.getFactory().newTask();
InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
WorkItem workItem = new WorkItemImpl();
workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId);
peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
OrganizationalEntity organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
assertTrue(organizationalEntity1 instanceof User);
assertEquals(actorId, organizationalEntity1.getId());
assertEquals(actorId, taskData.getCreatedBy().getId());
workItem = new WorkItemImpl();
peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId + ", drbug ");
peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
assertEquals(2, peopleAssignments.getPotentialOwners().size());
organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
assertEquals(actorId, organizationalEntity1.getId());
assertEquals(actorId, taskData.getCreatedBy().getId());
OrganizationalEntity organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
assertEquals("drbug", organizationalEntity2.getId());
workItem = new WorkItemImpl();
peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, "");
peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
assertEquals(0, peopleAssignments.getPotentialOwners().size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class PeopleAssignmentHelperTest method testHandlePeopleAssignments.
@Test
public void testHandlePeopleAssignments() {
InternalTask task = (InternalTask) TaskModelProvider.getFactory().newTask();
InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
InternalPeopleAssignments peopleAssignment = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
assertNotNull(peopleAssignment);
assertEquals(0, peopleAssignment.getPotentialOwners().size());
assertEquals(0, peopleAssignment.getBusinessAdministrators().size());
assertEquals(0, peopleAssignment.getTaskStakeholders().size());
String actorId = "espiegelberg";
String taskStakeholderId = "drmary";
String businessAdministratorId = "drbug";
String businessAdministratorGroupId = "Super users";
String excludedOwnerId = "john";
String recipientId = "mary";
WorkItem workItem = new WorkItemImpl();
workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId);
workItem.setParameter(PeopleAssignmentHelper.TASKSTAKEHOLDER_ID, taskStakeholderId);
workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_ID, businessAdministratorId);
workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_GROUP_ID, businessAdministratorGroupId);
workItem.setParameter(PeopleAssignmentHelper.EXCLUDED_OWNER_ID, excludedOwnerId);
workItem.setParameter(PeopleAssignmentHelper.RECIPIENT_ID, recipientId);
peopleAssignmentHelper.handlePeopleAssignments(workItem, task, taskData);
List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners();
assertEquals(1, potentialOwners.size());
assertEquals(actorId, potentialOwners.get(0).getId());
List<OrganizationalEntity> businessAdministrators = task.getPeopleAssignments().getBusinessAdministrators();
assertEquals(4, businessAdministrators.size());
assertEquals("Administrator", businessAdministrators.get(0).getId());
// Admin group
assertEquals("Administrators", businessAdministrators.get(1).getId());
assertEquals(businessAdministratorId, businessAdministrators.get(2).getId());
assertEquals(businessAdministratorGroupId, businessAdministrators.get(3).getId());
List<OrganizationalEntity> taskStakehoders = ((InternalPeopleAssignments) task.getPeopleAssignments()).getTaskStakeholders();
assertEquals(1, taskStakehoders.size());
assertEquals(taskStakeholderId, taskStakehoders.get(0).getId());
List<OrganizationalEntity> excludedOwners = ((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners();
assertEquals(1, excludedOwners.size());
assertEquals(excludedOwnerId, excludedOwners.get(0).getId());
List<OrganizationalEntity> recipients = ((InternalPeopleAssignments) task.getPeopleAssignments()).getRecipients();
assertEquals(1, recipients.size());
assertEquals(recipientId, recipients.get(0).getId());
}
Aggregations