Search in sources :

Example 81 with TaskQuery

use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.

the class ConditionalEventTriggeredByExecutionListenerTest method testSetVariableInTakeListenerWithAsyncBefore.

@Test
public void testSetVariableInTakeListenerWithAsyncBefore() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaAsyncBefore().endEvent(END_EVENT_ID).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);
    modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
    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();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then take listener sets variable
    // conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
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 82 with TaskQuery

use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.

the class ConditionalEventTriggeredByExecutionListenerTest method testNonInterruptingSetVariableOnParentScopeInStartListener.

@Test
public void testNonInterruptingSetVariableOnParentScopeInStartListener() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).subProcess().embeddedSubProcess().startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_START, EXPR_SET_VARIABLE_ON_PARENT).endEvent().subProcessDone().endEvent(END_EVENT_ID).done();
    modelInstance = specifier.specifyConditionalProcess(modelInstance, false);
    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();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then start listener sets variable
    // non interrupting boundary event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    specifier.assertTaskNames(tasksAfterVariableIsSet, false, false);
}
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 83 with TaskQuery

use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.

the class ConditionalEventTriggeredByExecutionListenerTest method testNonInterruptingSetVariableInTakeListenerWithAsyncBefore.

@Test
public void testNonInterruptingSetVariableInTakeListenerWithAsyncBefore() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaAsyncBefore().endEvent(END_EVENT_ID).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);
    modelInstance = specifier.specifyConditionalProcess(modelInstance, false);
    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());
    // when task is completed
    taskService.complete(taskQuery.singleResult().getId());
    // then take listener sets variable
    // non interrupting boundary event is triggered
    specifier.assertTaskNames(taskQuery.list(), false, true);
    // and job was created
    Job job = engine.getManagementService().createJobQuery().singleResult();
    assertNotNull(job);
    assertEquals(1, conditionEventSubscriptionQuery.list().size());
    // when job is executed task is created
    engine.getManagementService().executeJob(job.getId());
    // when tasks are completed
    for (Task task : taskQuery.list()) {
        taskService.complete(task.getId());
    }
    // then no task exist and process instance is ended
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(0, tasksAfterVariableIsSet.size());
    assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
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) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 84 with TaskQuery

use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.

the class ConditionalEventTriggeredByExecutionListenerTest method testSetVariableOnParentScopeInTakeListener.

@Test
public void testSetVariableOnParentScopeInTakeListener() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).subProcess().embeddedSubProcess().startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).endEvent().subProcessDone().endEvent(END_EVENT_ID).done();
    CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
    listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
    listener.setCamundaExpression(EXPR_SET_VARIABLE_ON_PARENT);
    modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
    modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
    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();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then start listener sets variable
    // conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
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 85 with TaskQuery

use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.

the class ConditionalEventTriggeredByExecutionListenerTest method testNonInterruptingSetVariableInEndListener.

@Test
public void testNonInterruptingSetVariableInEndListener() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_END, EXPR_SET_VARIABLE).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).endEvent(END_EVENT_ID).done();
    modelInstance = specifier.specifyConditionalProcess(modelInstance, false);
    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());
    // when task is completed
    taskService.complete(taskQuery.singleResult().getId());
    // then end listener sets variable
    // non interrupting boundary event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(specifier.expectedTaskCount(), tasksAfterVariableIsSet.size());
    specifier.assertTaskNames(tasksAfterVariableIsSet, false, false);
}
Also used : 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