当前位置: 首页>>代码示例>>Java>>正文


Java CamundaExecutionListener.setCamundaEvent方法代码示例

本文整理汇总了Java中org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener.setCamundaEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CamundaExecutionListener.setCamundaEvent方法的具体用法?Java CamundaExecutionListener.setCamundaEvent怎么用?Java CamundaExecutionListener.setCamundaEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener的用法示例。


在下文中一共展示了CamundaExecutionListener.setCamundaEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExecutionListenerExtension

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@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);
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:25,代码来源:CamundaExtensionsTest.java

示例2: testSetLocalScopeWithExecutionListenerTake

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testSetLocalScopeWithExecutionListenerTake() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process")
    .startEvent().id("activityId")
    .sequenceFlowId("sequenceFlow")
    .endEvent()
    .done();

  CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
  listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
  listener.setCamundaClass(ExecutionListener.class.getName());
  modelInstance.<SequenceFlow>getModelElementById("sequenceFlow").builder().addExtensionElement(listener);

  testHelper.deploy(modelInstance);
  engineRule.getRuntimeService().startProcessInstanceByKey("process");
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TargetVariableScopeTest.java

示例3: tweakGateway

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
protected void tweakGateway(ExclusiveGateway xorGateway) {
  ModelInstance bpmn = xorGateway.getModelInstance();

  double probabilitySum = 0;
  // Process Variable used to store sample from distribution to decide for
  // outgoing transition
  String var = "SIM_SAMPLE_VALUE_" + xorGateway.getId().replaceAll("-", "_");

  Collection<SequenceFlow> flows = xorGateway.getOutgoing();
  if (flows.size() > 1) { // if outgoing flows = 1 it is a joining gateway
    for (SequenceFlow sequenceFlow : flows) {
      double probability = readCamundaProperty(sequenceFlow, "probability").map(Double::valueOf).orElse(1.0);

      ConditionExpression conditionExpression = bpmn.newInstance(ConditionExpression.class);
      conditionExpression.setTextContent("#{" + var + " >= " + probabilitySum + " && " + var + " < " + (probabilitySum + probability) + "}");
      sequenceFlow.setConditionExpression(conditionExpression);

      probabilitySum += probability;
    }

    // add execution listener to do decision based on random which corresponds
    // to configured probabilities
    // (because of expressions on outgoing sequence flows)
    CamundaExecutionListener executionListener = bpmn.newInstance(CamundaExecutionListener.class);
    executionListener.setCamundaEvent("start");
    CamundaScript script = bpmn.newInstance(CamundaScript.class);
    script.setTextContent(//
        "sample = com.camunda.demo.environment.simulation.StatisticsHelper.nextSample(" + probabilitySum + ");\n" + "execution.setVariable('" + var
            + "', sample);");
    script.setCamundaScriptFormat("Javascript");
    executionListener.setCamundaScript(script);

    if (xorGateway.getExtensionElements() == null) {
      ExtensionElements extensionElements = bpmn.newInstance(ExtensionElements.class);
      xorGateway.addChildElement(extensionElements);
    }
    xorGateway.getExtensionElements().addChildElement(executionListener);
  }
}
 
开发者ID:camunda-consulting,项目名称:camunda-util-demo-data-generator,代码行数:40,代码来源:DemoModelInstrumentator.java

示例4: camundaExecutionListenerClass

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
public B camundaExecutionListenerClass(String eventName, String fullQualifiedClassName) {
  CamundaExecutionListener executionListener = createInstance(CamundaExecutionListener.class);
  executionListener.setCamundaEvent(eventName);
  executionListener.setCamundaClass(fullQualifiedClassName);

  addExtensionElement(executionListener);

  return myself;
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:10,代码来源:AbstractFlowNodeBuilder.java

示例5: camundaExecutionListenerExpression

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
public B camundaExecutionListenerExpression(String eventName, String expression) {
  CamundaExecutionListener executionListener = createInstance(CamundaExecutionListener.class);
  executionListener.setCamundaEvent(eventName);
  executionListener.setCamundaExpression(expression);

  addExtensionElement(executionListener);

  return myself;
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:10,代码来源:AbstractFlowNodeBuilder.java

示例6: camundaExecutionListenerDelegateExpression

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
public B camundaExecutionListenerDelegateExpression(String eventName, String delegateExpression) {
  CamundaExecutionListener executionListener = createInstance(CamundaExecutionListener.class);
  executionListener.setCamundaEvent(eventName);
  executionListener.setCamundaDelegateExpression(delegateExpression);

  addExtensionElement(executionListener);

  return myself;
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:10,代码来源:AbstractFlowNodeBuilder.java

示例7: createModelAccessTask

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
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;
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:10,代码来源:ListenerProcessEngineServicesAccessTest.java

示例8: testSetVariableInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testSetVariableInTakeListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent(START_EVENT_ID)
    .userTask(TASK_BEFORE_CONDITION_ID)
      .name(TASK_BEFORE_CONDITION)
    .sequenceFlowId(FLOW_ID)
    .userTask(TASK_WITH_CONDITION_ID)
      .name(TASK_WITH_CONDITION)
    .endEvent(END_EVENT_ID)
    .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);
  modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  // 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();
  specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:35,代码来源:ConditionalEventTriggeredByExecutionListenerTest.java

示例9: testNonInterruptingSetVariableInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testNonInterruptingSetVariableInTakeListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent(START_EVENT_ID)
    .userTask(TASK_BEFORE_CONDITION_ID)
      .name(TASK_BEFORE_CONDITION)
    .sequenceFlowId(FLOW_ID)
    .userTask(TASK_WITH_CONDITION_ID)
      .name(TASK_WITH_CONDITION)
    .endEvent(END_EVENT_ID)
    .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);
  modelInstance = specifier.specifyConditionalProcess(modelInstance, false);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  // 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(specifier.expectedTaskCount(), tasksAfterVariableIsSet.size());
  assertEquals(specifier.expectedSubscriptions(), conditionEventSubscriptionQuery.list().size());
  specifier.assertTaskNames(tasksAfterVariableIsSet, false, false);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:37,代码来源:ConditionalEventTriggeredByExecutionListenerTest.java

示例10: testSetVariableInTakeListenerWithAsyncBefore

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testSetVariableInTakeListenerWithAsyncBefore() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent(START_EVENT_ID)
    .userTask(TASK_BEFORE_CONDITION_ID)
      .name(TASK_BEFORE_CONDITION)
    .sequenceFlowId(FLOW_ID)
    .userTask(TASK_WITH_CONDITION_ID)
      .name(TASK_WITH_CONDITION)
      .camundaAsyncBefore()
    .endEvent(END_EVENT_ID)
    .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);
  modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  // 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();
  specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:36,代码来源:ConditionalEventTriggeredByExecutionListenerTest.java

示例11: testSetVariableOnParentScopeInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testSetVariableOnParentScopeInTakeListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent(START_EVENT_ID)
    .subProcess()
    .embeddedSubProcess()
    .startEvent()
      .userTask(TASK_BEFORE_CONDITION_ID)
        .name(TASK_BEFORE_CONDITION)
      .sequenceFlowId(FLOW_ID)
      .userTask(TASK_WITH_CONDITION_ID)
        .name(TASK_WITH_CONDITION)
      .endEvent()
    .subProcessDone()
    .endEvent(END_EVENT_ID)
    .done();
  CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
  listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
  listener.setCamundaExpression(EXPR_SET_VARIABLE_ON_PARENT);
  modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
  modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  // 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 start listener sets variable
  //conditional event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:40,代码来源:ConditionalEventTriggeredByExecutionListenerTest.java

示例12: testNonInterruptingSetVariableOnParentScopeInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testNonInterruptingSetVariableOnParentScopeInTakeListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent(START_EVENT_ID)
    .subProcess()
    .embeddedSubProcess()
      .startEvent()
      .userTask(TASK_BEFORE_CONDITION_ID)
        .name(TASK_BEFORE_CONDITION)
      .sequenceFlowId(FLOW_ID)
        .userTask(TASK_WITH_CONDITION_ID)
        .name(TASK_WITH_CONDITION)
      .endEvent()
    .subProcessDone()
    .endEvent(END_EVENT_ID)
    .done();
  CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
  listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
  listener.setCamundaExpression(EXPR_SET_VARIABLE_ON_PARENT);
  modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
  modelInstance = specifier.specifyConditionalProcess(modelInstance, false);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  // 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 start listener sets variable
  //non interrupting boundary event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  specifier.assertTaskNames(tasksAfterVariableIsSet, false, false);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:40,代码来源:ConditionalEventTriggeredByExecutionListenerTest.java

示例13: testSetVariableInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:33,代码来源:BoundaryConditionalEventTest.java

示例14: testNonInterruptingSetVariableInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testNonInterruptingSetVariableInTakeListener() {
  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, 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 with default evaluation behavior
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(2, tasksAfterVariableIsSet.size());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:33,代码来源:BoundaryConditionalEventTest.java

示例15: testSetVariableInTakeListener

import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener; //导入方法依赖的package包/类
@Test
public void testSetVariableInTakeListener() {
  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(), 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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:33,代码来源:TriggerConditionalEventFromDelegationCodeTest.java


注:本文中的org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener.setCamundaEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。