use of org.camunda.bpm.engine.delegate.TaskListener in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testTaskListener.
@Deployment
public void testTaskListener() {
final List<String> events = new ArrayList<String>();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public TaskListener getTaskListener() {
return new TaskListener() {
public void notify(DelegateTask delegateTask) {
events.add(delegateTask.getEventName());
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// start process instance
ProcessInstance taskListenerProcess = runtimeService.startProcessInstanceByKey("taskListenerProcess");
// create event received
assertEquals(1, events.size());
assertEquals(TaskListener.EVENTNAME_CREATE, events.get(0));
Task task = taskService.createTaskQuery().singleResult();
// assign task:
taskService.setAssignee(task.getId(), "jonny");
assertEquals(2, events.size());
assertEquals(TaskListener.EVENTNAME_ASSIGNMENT, events.get(1));
// complete task
taskService.complete(task.getId());
assertEquals(4, events.size());
assertEquals(TaskListener.EVENTNAME_COMPLETE, events.get(2));
// next task was created
assertEquals(TaskListener.EVENTNAME_CREATE, events.get(3));
// delete process instance so last task will be deleted
runtimeService.deleteProcessInstance(taskListenerProcess.getProcessInstanceId(), "test delete event");
assertEquals(5, events.size());
assertEquals(TaskListener.EVENTNAME_DELETE, events.get(4));
}
Aggregations