use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class TransientVariableTest method testParallelProcessWithSetVariableTransientAfterReachingEventBasedGW.
@Test
public void testParallelProcessWithSetVariableTransientAfterReachingEventBasedGW() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_PROCESS_KEY).startEvent().parallelGateway().id("parallel").userTask("taskBeforeGw").eventBasedGateway().id("evenBased").intermediateCatchEvent().conditionalEventDefinition().condition(VAR_CONDITION).camundaVariableEvents(Arrays.asList("create", "update")).conditionalEventDefinitionDone().userTask().name("taskAfter").endEvent().moveToNode("parallel").userTask("taskBefore").serviceTask().camundaClass(SetVariableTransientDelegate.class.getName()).endEvent().done();
testRule.deploy(modelInstance);
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task taskBeforeEGW = taskService.createTaskQuery().taskDefinitionKey("taskBeforeGw").singleResult();
Task taskBeforeServiceTask = taskService.createTaskQuery().taskDefinitionKey("taskBefore").singleResult();
// when task before event based gateway is completed and after that task before service task
taskService.complete(taskBeforeEGW.getId());
taskService.complete(taskBeforeServiceTask.getId());
// then event based gateway is reached and executions stays there
// variable is set after reaching event based gateway
// after setting variable the conditional event is triggered and evaluated to true
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskAfter", task.getName());
// completing this task ends process instance
taskService.complete(task.getId());
assertNull(taskQuery.singleResult());
assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testWrongVariableCondition.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testVariableCondition.bpmn20.xml" })
public void testWrongVariableCondition() {
// 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());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
// when wrong variable is set on task execution
taskService.setVariable(task.getId(), VARIABLE_NAME + 1, 1);
// then execution stays at user task with condition
task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_WITH_CONDITION, task.getName());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
// when correct variable is set
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// then execution is on user task after condition
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testSubProcessSetVariableOnExecutionCondition.
@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());
}
use of org.camunda.bpm.engine.task.TaskQuery 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());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testSetVariableInInMappingOfCallActivity.
@Test
public void testSetVariableInInMappingOfCallActivity() {
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).camundaIn(VARIABLE_NAME, VARIABLE_NAME).userTask().name(TASK_AFTER_OUTPUT_MAPPING).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 in mapping from call activity sets variable
// -> interrupting conditional event is not triggered, since variable is only locally
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_OUTPUT_MAPPING, tasksAfterVariableIsSet.get(0).getName());
}
Aggregations