use of org.kie.server.api.model.instance.TaskEventInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceIntegrationTest method testFindTaskEventsSortedBy.
@Test
public void testFindTaskEventsSortedBy() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
try {
List<TaskSummary> tasks = taskClient.findTasksByStatusByProcessInstanceId(processInstanceId, null, 0, 10);
assertNotNull(tasks);
assertEquals(1, tasks.size());
TaskSummary taskInstance = tasks.get(0);
taskClient.startTask(CONTAINER_ID, taskInstance.getId(), USER_YODA);
taskClient.stopTask(CONTAINER_ID, taskInstance.getId(), USER_YODA);
List<TaskEventInstance> events = taskClient.findTaskEvents(CONTAINER_ID, taskInstance.getId(), 0, 4, SORT_BY_TASK_EVENTS_TYPE, true);
assertEquals(TaskEvent.TaskEventType.ACTIVATED.toString(), events.get(0).getType());
assertEquals(TaskEvent.TaskEventType.ADDED.toString(), events.get(1).getType());
assertEquals(TaskEvent.TaskEventType.STARTED.toString(), events.get(2).getType());
assertEquals(TaskEvent.TaskEventType.STOPPED.toString(), events.get(3).getType());
try {
events = taskClient.findTaskEvents(CONTAINER_ID, taskInstance.getId(), 2, 3, SORT_BY_TASK_EVENTS_TYPE, true);
KieServerAssert.assertNullOrEmpty("Task events list is not empty.", events);
} catch (KieServicesException ee) {
if (configuration.isRest()) {
KieServerAssert.assertResultContainsString(ee.getMessage(), "Could not find task instance with id " + taskInstance.getId());
KieServicesHttpException httpEx = (KieServicesHttpException) ee;
assertEquals(Integer.valueOf(404), httpEx.getHttpCode());
} else {
assertTrue(ee.getMessage().contains("No task found with id " + taskInstance.getId()));
}
}
events = taskClient.findTaskEvents(CONTAINER_ID, taskInstance.getId(), 0, 4, SORT_BY_TASK_EVENTS_TYPE, false);
assertEquals(TaskEvent.TaskEventType.STOPPED.toString(), events.get(0).getType());
assertEquals(TaskEvent.TaskEventType.STARTED.toString(), events.get(1).getType());
assertEquals(TaskEvent.TaskEventType.ADDED.toString(), events.get(2).getType());
assertEquals(TaskEvent.TaskEventType.ACTIVATED.toString(), events.get(3).getType());
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
Aggregations