Search in sources :

Example 21 with TaskListener

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));
}
Also used : DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) ArrayList(java.util.ArrayList) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

TaskListener (org.camunda.bpm.engine.delegate.TaskListener)21 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)16 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)16 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)16 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)14 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)12 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)12 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)12 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)12 Test (org.junit.Test)12 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)4 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)2 TaskListenerInvocation (org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation)2 Element (org.camunda.bpm.engine.impl.util.xml.Element)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 ArrayList (java.util.ArrayList)1 ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)1 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)1 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)1 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)1