Search in sources :

Example 11 with CamundaExecutionListener

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpm-platform by camunda.

the class TriggerConditionalEventFromDelegationCodeTest method testSetVariableInTakeListenerWithAsyncBefore.

@Test
public void testSetVariableInTakeListenerWithAsyncBefore() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).camundaAsyncBefore().endEvent().done();
    CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
    listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
    listener.setCamundaClass(specifier.getDelegateClass().getName());
    modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
    deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, specifier.getCondition(), true);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    Task task = taskQuery.singleResult();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then take listener sets variable
    // conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(specifier.getExpectedInterruptingCount(), taskQuery.taskName(TASK_AFTER_CONDITION).count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 12 with CamundaExecutionListener

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpm-platform by camunda.

the class TriggerConditionalEventFromDelegationCodeTest method testNonInterruptingSetVariableInTakeListenerWithAsyncBefore.

@Test
public void testNonInterruptingSetVariableInTakeListenerWithAsyncBefore() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).camundaAsyncBefore().endEvent().done();
    CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
    listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
    listener.setCamundaClass(specifier.getDelegateClass().getName());
    modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
    deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, specifier.getCondition(), false);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    // when task is completed
    taskService.complete(taskQuery.singleResult().getId());
    // then take listener sets variable
    // non interrupting boundary event is triggered
    assertEquals(specifier.getExpectedNonInterruptingCount(), taskService.createTaskQuery().taskName(TASK_AFTER_CONDITION).count());
    // and job was created
    Job job = engine.getManagementService().createJobQuery().singleResult();
    assertNotNull(job);
    // when job is executed task is created
    engine.getManagementService().executeJob(job.getId());
    // when all tasks are completed
    assertEquals(specifier.getExpectedNonInterruptingCount() + 1, taskQuery.count());
    for (Task task : taskQuery.list()) {
        taskService.complete(task.getId());
    }
    // then no task exist and process instance is ended
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(0, tasksAfterVariableIsSet.size());
    assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
Also used : Task(org.camunda.bpm.engine.task.Task) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 13 with CamundaExecutionListener

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpm-platform by camunda.

the class ListenerProcessEngineServicesAccessTest method createModelAccessTask.

protected Task createModelAccessTask(BpmnModelInstance modelInstance, Class<?> delegateClass) {
    ManualTask task = modelInstance.newInstance(ManualTask.class);
    task.setId("manualTask");
    CamundaExecutionListener executionListener = modelInstance.newInstance(CamundaExecutionListener.class);
    executionListener.setCamundaEvent(ExecutionListener.EVENTNAME_START);
    executionListener.setCamundaClass(delegateClass.getName());
    task.builder().addExtensionElement(executionListener);
    return task;
}
Also used : ManualTask(org.camunda.bpm.model.bpmn.instance.ManualTask) CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)

Example 14 with CamundaExecutionListener

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.

the class AbstractFlowNodeBuilder method camundaExecutionListenerExpression.

public B camundaExecutionListenerExpression(String eventName, String expression) {
    CamundaExecutionListener executionListener = createInstance(CamundaExecutionListener.class);
    executionListener.setCamundaEvent(eventName);
    executionListener.setCamundaExpression(expression);
    addExtensionElement(executionListener);
    return myself;
}
Also used : CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)

Example 15 with CamundaExecutionListener

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.

the class AbstractFlowNodeBuilder method camundaExecutionListenerClass.

public B camundaExecutionListenerClass(String eventName, String fullQualifiedClassName) {
    CamundaExecutionListener executionListener = createInstance(CamundaExecutionListener.class);
    executionListener.setCamundaEvent(eventName);
    executionListener.setCamundaClass(fullQualifiedClassName);
    addExtensionElement(executionListener);
    return myself;
}
Also used : CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)

Aggregations

CamundaExecutionListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)24 Test (org.junit.Test)19 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)13 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 Task (org.camunda.bpm.engine.task.Task)12 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)12 Job (org.camunda.bpm.engine.runtime.Job)2 ManualTask (org.camunda.bpm.model.bpmn.instance.ManualTask)1 CamundaScript (org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1