use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method testGetTasksByVariousFieldsWithUserGroupCallbackAdminByParams.
@Test
public void testGetTasksByVariousFieldsWithUserGroupCallbackAdminByParams() {
String busAdmin = "Administrator";
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "businessAdministrators = [new Group('Administrators')]," + "potentialOwners = [new Group('Crusaders')]" + " }),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
((InternalTaskData) task.getTaskData()).setWorkItemId(1);
((InternalTaskData) task.getTaskData()).setProcessInstanceId(1);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> results = taskService.taskSummaryQuery("Crusaders").businessAdmin(busAdmin).build().getResultList();
assertNotNull(results);
assertEquals(1, results.size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method testGetTasksByVariousFieldsWithUserGroupCallback.
@Test
public void testGetTasksByVariousFieldsWithUserGroupCallback() {
String potOwner = "Bobba Fet";
List<String> potOwners = new ArrayList<String>();
potOwners.add(potOwner);
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "businessAdministrators = [new Group('Administrators')]," + "potentialOwners = [new Group('Crusaders')]" + " }),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
((InternalTaskData) task.getTaskData()).setWorkItemId(1);
((InternalTaskData) task.getTaskData()).setProcessInstanceId(1);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> results = taskService.taskSummaryQuery("Administrator").potentialOwner(potOwner).build().getResultList();
assertNotNull(results);
assertEquals(1, results.size());
TaskSummary resultTask = results.get(0);
// "Wintermute" does not have the proper permissions
results = taskService.taskSummaryQuery("Wintermute").potentialOwner(potOwner).build().getResultList();
assertEquals(0, results.size());
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class DeadlinesBaseTest 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
assertThat(((MockNotificationListener) notificationListener).getEventsRecieved().size()).isEqualTo(0);
countDownListener.waitTillCompleted();
// no email should ne sent as task was completed before deadline was triggered
assertThat(((MockNotificationListener) notificationListener).getEventsRecieved().size()).isEqualTo(0);
task = (InternalTask) taskService.getTaskById(taskId);
assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Completed);
assertThat(((InternalTask) task).getDeadlines().getStartDeadlines().size()).isEqualTo(0);
assertThat(((InternalTask) task).getDeadlines().getEndDeadlines().size()).isEqualTo(0);
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class DeadlinesBaseTest method testDelayedEmailNotificationOnDeadlineTaskCompletedMultipleTasks.
@Test(timeout = 12000)
public void testDelayedEmailNotificationOnDeadlineTaskCompletedMultipleTasks() throws Exception {
CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(2, 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));
// create task 1
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);
// create task 2
reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
InternalTask task2 = (InternalTask) TaskFactory.evalTask(reader, vars);
((InternalTaskData) task2.getTaskData()).setSkipable(true);
task2.setPeopleAssignments(assignments);
taskService.addTask(task, new HashMap<String, Object>());
taskService.addTask(task2, 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);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 5);
task.getDeadlines().getStartDeadlines().get(0).setDate(cal.getTime());
task2.getDeadlines().getStartDeadlines().get(0).setDate(cal.getTime());
taskService.start(taskId, "Administrator");
taskService.complete(taskId, "Administrator", null);
// emails should not be set yet
assertThat(((MockNotificationListener) notificationListener).getEventsRecieved().size()).isEqualTo(0);
countDownListener.waitTillCompleted();
// no email should be sent as task was completed before deadline was triggered
assertThat(((MockNotificationListener) notificationListener).getEventsRecieved().size()).isEqualTo(1);
task = (InternalTask) taskService.getTaskById(taskId);
assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Completed);
assertThat(((InternalTask) task).getDeadlines().getStartDeadlines().size()).isEqualTo(0);
assertThat(((InternalTask) task).getDeadlines().getEndDeadlines().size()).isEqualTo(0);
taskService.start(task2.getId(), "Administrator");
taskService.complete(task2.getId(), "Administrator", null);
task = (InternalTask) taskService.getTaskById(task2.getId());
assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Completed);
assertThat(((InternalTask) task).getDeadlines().getStartDeadlines().size()).isEqualTo(0);
assertThat(((InternalTask) task).getDeadlines().getEndDeadlines().size()).isEqualTo(0);
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class EmailDeadlinesBaseTest method testDelayedEmailNotificationStartDeadlineStatusDoesNotMatch.
@Test(timeout = 10000)
public void testDelayedEmailNotificationStartDeadlineStatusDoesNotMatch() throws Exception {
CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(2, 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");
// emails should not be set yet
assertEquals(0, getWiser().getMessages().size());
// since we don't want the notification to be invoked we need to rely on timeout
countDownListener.waitTillCompleted(3000);
// 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.InProgress, task.getTaskData().getStatus());
assertEquals(0, task.getDeadlines().getStartDeadlines().size());
assertEquals(0, task.getDeadlines().getEndDeadlines().size());
}
Aggregations