use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInInputMappingOfSubProcess.
@Test
public void testNonInterruptingSetVariableInInputMappingOfSubProcess() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask().name(TASK_BEFORE_CONDITION).subProcess(SUB_PROCESS_ID).camundaInputParameter(VARIABLE_NAME, "1").embeddedSubProcess().startEvent().userTask().name(TASK_IN_SUB_PROCESS_ID).endEvent().subProcessDone().endEvent().done();
deployConditionalBoundaryEventProcess(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 before is completed
taskService.complete(task.getId());
// Then input mapping from sub process sets variable, but
// non interrupting conditional event is not triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_IN_SUB_PROCESS_ID, tasksAfterVariableIsSet.get(0).getName());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInOutputMappingOfCallActivity.
@Test
public void testNonInterruptingSetVariableInOutputMappingOfCallActivity() {
engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, DELEGATED_PROCESS).deploy());
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).callActivity(TASK_WITH_CONDITION_ID).calledElement(DELEGATED_PROCESS_KEY).camundaOutputParameter(VARIABLE_NAME, "1").userTask().name(TASK_AFTER_OUTPUT_MAPPING).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 before service task is completed
taskService.complete(task.getId());
// then out mapping of call activity sets a variable
// -> non interrupting conditional event is not triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_OUTPUT_MAPPING, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInMultiInstance.
@Test
public void testNonInterruptingSetVariableInMultiInstance() {
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").parallel().done();
deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, "${nrOfInstances == 3}", 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 multi instance is created
// and boundary event is triggered for each multi instance creation
List<Task> multiInstanceTasks = taskQuery.taskDefinitionKey(TASK_WITH_CONDITION_ID).list();
assertEquals(3, multiInstanceTasks.size());
assertEquals(3, taskService.createTaskQuery().taskName(TASK_AFTER_CONDITION).count());
// when multi instances are completed
for (Task multiInstanceTask : multiInstanceTasks) {
taskService.complete(multiInstanceTask.getId());
}
// then non boundary events are triggered
tasksAfterVariableIsSet = taskService.createTaskQuery().list();
assertEquals(9, tasksAfterVariableIsSet.size());
assertEquals(0, conditionEventSubscriptionQuery.list().size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInTakeListener.
@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());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class ConditionalEventWithSpecificVariableEventTest method testNonInterruptingVariableConditionWithVariableNameAndEvents.
@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
// create
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// update
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// delete
taskService.removeVariable(task.getId(), VARIABLE_NAME);
// 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());
}
Aggregations