use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testNonInterruptingSetVariableInOutMappingOfCallActivity.
@Test
public void testNonInterruptingSetVariableInOutMappingOfCallActivity() {
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).camundaOut(VARIABLE_NAME, VARIABLE_NAME).userTask().name(TASK_AFTER_OUTPUT_MAPPING).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 out mapping of call activity sets a variable
// -> non interrupting conditional event is triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(2, tasksAfterVariableIsSet.size());
assertEquals(1, conditionEventSubscriptionQuery.count());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testFalseCondition.
@Test
@Deployment
public void testFalseCondition() {
// 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 stays at user task
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_BEFORE_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testVariableConditionAndStartingWithVar.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/EventSubProcessStartConditionalEventTest.testVariableCondition.bpmn20.xml" })
public void testVariableConditionAndStartingWithVar() {
// given process with event sub process conditional start event
Map<String, Object> vars = Variables.createVariables();
vars.put(VARIABLE_NAME, 1);
// when starting process with variable
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY, vars);
// then event sub process is triggered via default evaluation behavior
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
assertEquals(0, conditionEventSubscriptionQuery.list().size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testSetVariableInDelegateWithSynchronousEvent.
@Test
public void testSetVariableInDelegateWithSynchronousEvent() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask().name(TASK_BEFORE_CONDITION).serviceTask().camundaClass(SetVariableDelegate.class.getName()).endEvent().done();
modelInstance = modify(modelInstance).addSubProcessTo(CONDITIONAL_EVENT_PROCESS_KEY).triggerByEvent().embeddedSubProcess().startEvent().interrupting(true).conditionalEventDefinition(CONDITIONAL_EVENT).condition(CONDITION_EXPR).conditionalEventDefinitionDone().endEvent().done();
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();
// when task is completed
taskService.complete(task.getId());
// then service task with delegated code is called and variable is set
// -> conditional event is triggered and process instance ends
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(0, tasksAfterVariableIsSet.size());
assertEquals(0, conditionEventSubscriptionQuery.list().size());
assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest 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().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 is completed
taskService.complete(task.getId());
// then output mapping from call activity sets variable
// -> non interrupting conditional event is triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(2, tasksAfterVariableIsSet.size());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
Aggregations