Search in sources :

Example 71 with TaskQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 72 with TaskQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 73 with TaskQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 74 with TaskQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 75 with TaskQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

TaskQuery (org.camunda.bpm.engine.task.TaskQuery)517 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)230 Task (org.camunda.bpm.engine.task.Task)227 Test (org.junit.Test)224 Deployment (org.camunda.bpm.engine.test.Deployment)195 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)124 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)86 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)55 Filter (org.camunda.bpm.engine.filter.Filter)26 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)24 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)23 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)22 Execution (org.camunda.bpm.engine.runtime.Execution)22 Job (org.camunda.bpm.engine.runtime.Job)20 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)15 Date (java.util.Date)12 HashMap (java.util.HashMap)12 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)12 CamundaExecutionListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)12