Java Code Examples for org.camunda.bpm.engine.task.TaskQuery#list()

The following examples show how to use org.camunda.bpm.engine.task.TaskQuery#list() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment
public void testCleanUpConditionalEventSubscriptions() {
  //given process with boundary conditional event
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();

  assertEquals(1, conditionEventSubscriptionQuery.list().size());

  //when task is completed
  taskService.complete(task.getId());

  //then conditional subscription should be deleted
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(1, tasksAfterVariableIsSet.size());
  assertEquals(0, conditionEventSubscriptionQuery.list().size());
}
 
Example 2
Source File: TriggerConditionalEventFromDelegationCodeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInEndListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_BEFORE_CONDITION_ID)
    .name(TASK_BEFORE_CONDITION)
    .camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, specifier.getDelegateClass().getName())
    .userTask(TASK_WITH_CONDITION_ID)
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();
  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 end listener sets variable
  //non interrupting event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(1 + specifier.getExpectedNonInterruptingCount(), tasksAfterVariableIsSet.size());
  assertEquals(specifier.getExpectedNonInterruptingCount(), taskQuery.taskName(TASK_AFTER_CONDITION).count());
}
 
Example 3
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetVariableInExpression() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent().userTask().name(TASK_BEFORE_CONDITION)
                                                .serviceTask(TASK_WITH_CONDITION_ID)
                                                  .camundaExpression("${execution.setVariable(\"variable\", 1)}")
                                                .userTask().name(TASK_AFTER_SERVICE_TASK)
                                                .endEvent().done();
   deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, 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 service task with expression is called and variable is set
  //-> interrupting conditional event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 4
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testParallelVariableCondition.bpmn20.xml"})
public void testParallelSetVariableOnTaskCondition() {
  //given process with parallel user tasks and boundary conditional event
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);

  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  List<Task> tasks = taskQuery.list();
  assertEquals(2, tasks.size());

  Task task = tasks.get(0);

  //when variable is set on execution
  taskService.setVariable(task.getId(), VARIABLE_NAME, 1);

  //then both boundary event are triggered and process instance ends
  List<Execution> executions = runtimeService.createExecutionQuery()
          .processInstanceId(procInst.getId())
          .list();
  assertEquals(0, executions.size());

  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(0, tasksAfterVariableIsSet.size());
}
 
Example 5
Source File: ConditionalEventWithSpecificVariableEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonInterruptingVariableConditionWithVariableNameAndEvents() {

  //given process with non interrupting boundary conditional event and defined variable name and events
  final BpmnModelInstance modelInstance = specifier.getProcessWithVarNameAndEvents(false, CONDITIONAL_VAR_EVENTS);
  engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());

  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();
  assertNotNull(task);

  //when variable with name `variable` is set, updated and deleted
  taskService.setVariable(task.getId(), VARIABLE_NAME, 1); //create
  taskService.setVariable(task.getId(), VARIABLE_NAME, 1); //update
  taskService.removeVariable(task.getId(), VARIABLE_NAME); //delete

  //then execution is for two times at user task after conditional start event
  assertEquals(2, taskService.createTaskQuery().taskName(TASK_AFTER_CONDITION).count());
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(3, tasksAfterVariableIsSet.size());
  assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
 
Example 6
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testVariableCondition.bpmn20.xml"})
public void testVariableSetOnExecutionCondition() {
  //given process with boundary conditional event
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);

  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();
  assertNotNull(task);
  assertEquals(TASK_WITH_CONDITION, task.getName());

  //when variable is set on task execution
  taskService.setVariable(task.getId(), VARIABLE_NAME, 1);

  //then execution ends
  Execution execution = runtimeService.createExecutionQuery()
          .processInstanceId(procInst.getId())
          .activityId(TASK_WITH_CONDITION_ID)
          .singleResult();
  assertNull(execution);

  //and execution is at user task after boundary event
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 7
Source File: BoundaryTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testMultipleOutgoingSequenceFlowsOnSubprocess() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("interruptingTimer");

  Job job = managementService.createJobQuery().singleResult();
  assertNotNull(job);

  managementService.executeJob(job.getId());

  TaskQuery taskQuery = taskService.createTaskQuery();
  assertEquals(2, taskQuery.count());

  List<Task> tasks = taskQuery.list();

  for (Task task : tasks) {
    taskService.complete(task.getId());
  }

  assertProcessEnded(pi.getId());
}
 
Example 8
Source File: MixedConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetVariableOnInputMapping() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_BEFORE_CONDITION_ID)
    .name(TASK_BEFORE_CONDITION)
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaInputParameter(VARIABLE_NAME, "1")
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();

  deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, true);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();

  //when task before is completed
  taskService.complete(task.getId());

  //then conditional boundary event should triggered with the default evaluation behavior
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITIONAL_BOUNDARY_EVENT, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 9
Source File: MixedConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetVariableOnOutputMapping() {

  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaOutputParameter(VARIABLE_NAME, "1")
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();

  deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, true);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();

  //when task before is completed
  taskService.complete(task.getId());

  //then conditional boundary should not triggered but conditional start event
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITIONAL_START_EVENT, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 10
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetVariableInExpression() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent().userTask().name(TASK_BEFORE_CONDITION)
                                                .serviceTask(TASK_WITH_CONDITION_ID)
                                                  .camundaExpression(EXPR_SET_VARIABLE)
                                                .endEvent().done();
  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 service task with expression is called and variable is set
  //-> interrupting conditional event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 11
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testSubProcessVariableCondition.bpmn20.xml"})
public void testSubProcessSetVariableOnExecutionCondition() {
  //given process with boundary conditional event on sub process
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);

  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();
  assertNotNull(task);
  assertEquals(TASK_IN_SUB_PROCESS, task.getName());

  //when variable is set on task execution with condition
  runtimeService.setVariable(task.getExecutionId(), VARIABLE_NAME, 1);

  //then process instance ends
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(0, tasksAfterVariableIsSet.size());
}
 
Example 12
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment
public void testVariableCondition() {
  //given process with event sub process conditional start event
  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 variable is set on task with condition
  taskService.setVariable(task.getId(), VARIABLE_NAME, 1);

  //then execution is at user task after conditional start event
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 13
Source File: BoundaryTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testMultipleOutgoingSequenceFlowsOnSubprocessMi() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("interruptingTimer");

  Job job = managementService.createJobQuery().singleResult();
  assertNotNull(job);

  managementService.executeJob(job.getId());

  TaskQuery taskQuery = taskService.createTaskQuery();
  assertEquals(2, taskQuery.count());

  List<Task> tasks = taskQuery.list();

  for (Task task : tasks) {
    taskService.complete(task.getId());
  }

  assertProcessEnded(pi.getId());
}
 
Example 14
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInSubProcessInDelegatedCode() {

  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent()
                                                .userTask(TASK_BEFORE_CONDITION_ID)
                                                  .name(TASK_BEFORE_CONDITION)
                                                .subProcess(SUB_PROCESS_ID)
                                                .embeddedSubProcess()
                                                  .startEvent()
                                                  .serviceTask()
                                                  .camundaExpression(EXPR_SET_VARIABLE)
                                                  .userTask().name(TASK_AFTER_SERVICE_TASK)
                                                  .endEvent()
                                                .subProcessDone()
                                                .endEvent()
                                                .done();
   deployConditionalEventSubProcess(modelInstance, SUB_PROCESS_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 service task in sub process sets variable
  //conditional event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(2, tasksAfterVariableIsSet.size());
  assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
 
Example 15
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 16
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetVariableInInputMapping() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent().userTask().name(TASK_BEFORE_CONDITION)
                                                .serviceTask(TASK_WITH_CONDITION_ID)
                                                  .camundaInputParameter(VARIABLE_NAME, "1")
                                                  .camundaExpression(TRUE_CONDITION)
                                                .userTask().name(TASK_AFTER_SERVICE_TASK)
                                                .endEvent().done();
   deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, 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 service task with input mapping is called and variable is set
  //-> interrupting conditional event is not triggered
  //since variable is only locally
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_SERVICE_TASK, tasksAfterVariableIsSet.get(0).getName());
}
 
Example 17
Source File: BoundaryConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInOutputMapping() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent()
                                                .userTask(TASK_BEFORE_CONDITION_ID)
                                                  .name(TASK_BEFORE_CONDITION)
                                                  .camundaOutputParameter(VARIABLE_NAME, "1")
                                                .userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION)
                                                .endEvent()
                                                .done();
  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 with output mapping is completed
  taskService.complete(task.getId());

  //then output mapping sets variable
  //boundary event is triggered from default evaluation behavior
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(2, tasksAfterVariableIsSet.size());
}
 
Example 18
Source File: MixedConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonInterruptingSetVariableOnEndExecutionListenerInSubProcessWithBoundary() {

  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .subProcess(SUB_PROCESS_ID)
    .embeddedSubProcess()
    .startEvent()
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_END, EXPR_SET_VARIABLE)
    .name(TASK_WITH_CONDITION)
    .userTask().name(TASK_AFTER_OUTPUT_MAPPING)
    .endEvent()
    .subProcessDone()
    .endEvent()
    .done();

  modelInstance = addEventSubProcess(modelInstance, SUB_PROCESS_ID, TASK_AFTER_COND_START_EVENT_IN_SUB_PROCESS, false);
  deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, SUB_PROCESS_ID, false);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());

  //when task before is completed
  taskService.complete(taskQuery.singleResult().getId());

  //then all conditional events are triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(4, tasksAfterVariableIsSet.size());
}
 
Example 19
Source File: MixedConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonInterruptingSetVariableOnEndExecutionListenerInSubProcess() {

  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .subProcess(SUB_PROCESS_ID)
    .embeddedSubProcess()
    .startEvent()
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_END, EXPR_SET_VARIABLE)
    .name(TASK_WITH_CONDITION)
    .userTask().name(TASK_AFTER_OUTPUT_MAPPING)
    .endEvent()
    .subProcessDone()
    .endEvent()
    .done();

  deployMixedProcess(modelInstance, SUB_PROCESS_ID, false);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());

  //when task before is completed
  taskService.complete(taskQuery.singleResult().getId());

  //then conditional boundary should not triggered but conditional start event
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(2, tasksAfterVariableIsSet.size());
  assertTaskNames(tasksAfterVariableIsSet,
    TASK_AFTER_CONDITIONAL_START_EVENT,
    TASK_AFTER_OUTPUT_MAPPING);
}
 
Example 20
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInInputMapping() {
  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
                                                .startEvent().userTask().name(TASK_BEFORE_CONDITION)
                                                .serviceTask(TASK_WITH_CONDITION_ID)
                                                  .camundaInputParameter(VARIABLE_NAME, "1")
                                                  .camundaExpression(TRUE_CONDITION)
                                                .userTask().name(TASK_AFTER_SERVICE_TASK)
                                                .endEvent().done();
   deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, 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 before service task is completed
  taskService.complete(task.getId());

  //then service task with input mapping is called and variable is set
  //-> non interrupting conditional event is not triggered
  //since variable is only locally
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_SERVICE_TASK, tasksAfterVariableIsSet.get(0).getName());
}