use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.
the class CamundaExecutionListenerImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaExecutionListener.class, CAMUNDA_ELEMENT_EXECUTION_LISTENER).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaExecutionListener>() {
public CamundaExecutionListener newInstance(ModelTypeInstanceContext instanceContext) {
return new CamundaExecutionListenerImpl(instanceContext);
}
});
camundaEventAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_EVENT).namespace(CAMUNDA_NS).build();
camundaClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CLASS).namespace(CAMUNDA_NS).build();
camundaExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_EXPRESSION).namespace(CAMUNDA_NS).build();
camundaDelegateExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DELEGATE_EXPRESSION).namespace(CAMUNDA_NS).build();
SequenceBuilder sequenceBuilder = typeBuilder.sequence();
camundaFieldCollection = sequenceBuilder.elementCollection(CamundaField.class).build();
camundaScriptChild = sequenceBuilder.element(CamundaScript.class).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCamundaExecutionListenerByClass.
@Test
public void testCamundaExecutionListenerByClass() {
modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaExecutionListenerClass("start", this.getClass()).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(this.getClass().getName());
assertThat(executionListener.getCamundaEvent()).isEqualTo("start");
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCamundaExecutionListenerByExpression.
@Test
public void testCamundaExecutionListenerByExpression() {
modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaExecutionListenerExpression("start", "anExpression").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.getCamundaExpression()).isEqualTo("anExpression");
assertThat(executionListener.getCamundaEvent()).isEqualTo("start");
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCamundaExecutionListenerByDelegateExpression.
@Test
public void testCamundaExecutionListenerByDelegateExpression() {
modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaExecutionListenerDelegateExpression("start", "aDelegateExpression").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.getCamundaDelegateExpression()).isEqualTo("aDelegateExpression");
assertThat(executionListener.getCamundaEvent()).isEqualTo("start");
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testSetVariableInTakeListener.
@Test
public void testSetVariableInTakeListener() {
final 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).name(TASK_WITH_CONDITION).endEvent().done();
CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
listener.setCamundaExpression(EXPR_SET_VARIABLE);
modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, 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
// non interrupting boundary event is triggered with default evaluation behavior
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
Aggregations