use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInEndListener.
@Test
public void testNonInterruptingSetVariableInEndListener() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_END, EXPR_SET_VARIABLE).userTask().name(AFTER_TASK).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_WITH_CONDITION, task.getName());
// when task is completed
taskService.complete(task.getId());
// then end listener sets variable
// non interrupting boundary event is not triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(AFTER_TASK, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testFalseCondition.
@Test
@Deployment
public void testFalseCondition() {
// given process with boundary conditional event
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery();
Task task = taskQuery.processInstanceId(procInst.getId()).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 stays in task with boundary condition
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_WITH_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testParallelSetVariableOnExecutionCondition.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testParallelVariableCondition.bpmn20.xml" })
public void testParallelSetVariableOnExecutionCondition() {
// 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());
// when variable is set on execution
// taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
// then both boundary events 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());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testSubProcessSetVariableOnTaskCondition.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testSubProcessVariableCondition.bpmn20.xml" })
public void testSubProcessSetVariableOnTaskCondition() {
// 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
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// then process instance ends
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(0, tasksAfterVariableIsSet.size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInSeqMultiInstance.
@Test
public void testNonInterruptingSetVariableInSeqMultiInstance() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).multiInstance().cardinality("3").sequential().done();
deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, "${true}", 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());
// nrOfInstances, nrOfCompletedInstances, nrOfActiveInstances, loopCounter
for (int i = 0; i < 3; i++) {
Task multiInstanceTask = taskQuery.taskDefinitionKey(TASK_WITH_CONDITION_ID).singleResult();
assertNotNull(multiInstanceTask);
assertEquals(i == 0 ? 5 : 5 + i * 2, taskService.createTaskQuery().taskName(TASK_AFTER_CONDITION).count());
taskService.complete(multiInstanceTask.getId());
}
// then non boundary events are triggered 9 times
tasksAfterVariableIsSet = taskService.createTaskQuery().list();
assertEquals(9, tasksAfterVariableIsSet.size());
assertEquals(0, conditionEventSubscriptionQuery.list().size());
}
Aggregations