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;
}
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();
}
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);
}
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");
}
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());
}
Aggregations