Search in sources :

Example 16 with CamundaExecutionListener

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

the class AbstractFlowNodeBuilder method camundaExecutionListenerDelegateExpression.

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

Example 17 with CamundaExecutionListener

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

the class CamundaExtensionsTest method testCamundaScriptExecutionListener.

@Test
public void testCamundaScriptExecutionListener() {
    CamundaExecutionListener sequenceFlowListener = sequenceFlow.getExtensionElements().getElementsQuery().filterByType(CamundaExecutionListener.class).singleResult();
    CamundaScript script = sequenceFlowListener.getCamundaScript();
    assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
    assertThat(script.getCamundaResource()).isNull();
    assertThat(script.getTextContent()).isEqualTo("println 'Hello World'");
    CamundaScript newScript = modelInstance.newInstance(CamundaScript.class);
    newScript.setCamundaScriptFormat("groovy");
    newScript.setCamundaResource("test.groovy");
    sequenceFlowListener.setCamundaScript(newScript);
    script = sequenceFlowListener.getCamundaScript();
    assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
    assertThat(script.getCamundaResource()).isEqualTo("test.groovy");
    assertThat(script.getTextContent()).isEmpty();
}
Also used : CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) CamundaScript(org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript) Test(org.junit.Test)

Example 18 with CamundaExecutionListener

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

the class CamundaExtensionsTest method testExecutionListenerExtension.

@Test
public void testExecutionListenerExtension() {
    CamundaExecutionListener processListener = process.getExtensionElements().getElementsQuery().filterByType(CamundaExecutionListener.class).singleResult();
    CamundaExecutionListener startEventListener = startEvent.getExtensionElements().getElementsQuery().filterByType(CamundaExecutionListener.class).singleResult();
    CamundaExecutionListener serviceTaskListener = serviceTask.getExtensionElements().getElementsQuery().filterByType(CamundaExecutionListener.class).singleResult();
    assertThat(processListener.getCamundaClass()).isEqualTo(TEST_CLASS_XML);
    assertThat(processListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_XML);
    assertThat(startEventListener.getCamundaExpression()).isEqualTo(TEST_EXPRESSION_XML);
    assertThat(startEventListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_XML);
    assertThat(serviceTaskListener.getCamundaDelegateExpression()).isEqualTo(TEST_DELEGATE_EXPRESSION_XML);
    assertThat(serviceTaskListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_XML);
    processListener.setCamundaClass(TEST_CLASS_API);
    processListener.setCamundaEvent(TEST_EXECUTION_EVENT_API);
    startEventListener.setCamundaExpression(TEST_EXPRESSION_API);
    startEventListener.setCamundaEvent(TEST_EXECUTION_EVENT_API);
    serviceTaskListener.setCamundaDelegateExpression(TEST_DELEGATE_EXPRESSION_API);
    serviceTaskListener.setCamundaEvent(TEST_EXECUTION_EVENT_API);
    assertThat(processListener.getCamundaClass()).isEqualTo(TEST_CLASS_API);
    assertThat(processListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_API);
    assertThat(startEventListener.getCamundaExpression()).isEqualTo(TEST_EXPRESSION_API);
    assertThat(startEventListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_API);
    assertThat(serviceTaskListener.getCamundaDelegateExpression()).isEqualTo(TEST_DELEGATE_EXPRESSION_API);
    assertThat(serviceTaskListener.getCamundaEvent()).isEqualTo(TEST_EXECUTION_EVENT_API);
}
Also used : CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) Test(org.junit.Test)

Example 19 with CamundaExecutionListener

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

the class ProcessBuilderTest method testCamundaExecutionListenerByClassName.

@Test
public void testCamundaExecutionListenerByClassName() {
    modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaExecutionListenerClass("start", "aClass").endEvent().done();
    UserTask userTask = modelInstance.getModelElementById("task");
    ExtensionElements extensionElements = userTask.getExtensionElements();
    Collection<CamundaExecutionListener> executionListeners = extensionElements.getChildElementsByType(CamundaExecutionListener.class);
    assertThat(executionListeners).hasSize(1);
    CamundaExecutionListener executionListener = executionListeners.iterator().next();
    assertThat(executionListener.getCamundaClass()).isEqualTo("aClass");
    assertThat(executionListener.getCamundaEvent()).isEqualTo("start");
}
Also used : CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) Test(org.junit.Test)

Example 20 with CamundaExecutionListener

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

the class TriggerConditionalEventFromDelegationCodeTest method testNonInterruptingSetVariableInTakeListener.

@Test
public void testNonInterruptingSetVariableInTakeListener() {
    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).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());
    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
    // non interrupting boundary event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(1 + specifier.getExpectedNonInterruptingCount(), tasksAfterVariableIsSet.size());
    assertEquals(specifier.getExpectedNonInterruptingCount(), 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)

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