use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testStartTimerEventInEventSubProcess.
@Deployment
public void testStartTimerEventInEventSubProcess() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventInEventSubProcess");
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(1, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// execute existing timer job
managementService.executeJob(managementService.createJobQuery().list().get(0).getId());
assertEquals(0, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
// check if user task doesn't exist because timer start event is
// interrupting
assertEquals(0, taskQuery.count());
// check if execution doesn't exist because timer start event is
// interrupting
assertEquals(0, executionQuery.count());
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
assertEquals(0, processInstanceQuery.count());
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testStartTimerEventWithTwoEventSubProcesses.
@Deployment
public void testStartTimerEventWithTwoEventSubProcesses() {
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventWithTwoEventSubProcesses");
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(1, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(2, jobQuery.count());
// get all timer jobs ordered by dueDate
List<Job> orderedJobList = jobQuery.orderByJobDuedate().asc().list();
// execute first timer job
managementService.executeJob(orderedJobList.get(0).getId());
assertEquals(0, jobQuery.count());
// check if user task doesn't exist because timer start event is
// interrupting
assertEquals(0, taskQuery.count());
// check if execution doesn't exist because timer start event is
// interrupting
assertEquals(0, executionQuery.count());
// check if process instance doesn't exist because timer start event is
// interrupting
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
assertEquals(0, processInstanceQuery.count());
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testNonInterruptingStartTimerEventSubProcessInSubProcess.
@Deployment
public void testNonInterruptingStartTimerEventSubProcessInSubProcess() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingStartTimerEventSubProcessInSubProcess");
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(2, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// execute existing timer job
managementService.executeJob(jobQuery.list().get(0).getId());
assertEquals(0, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
// check if user task still exists because timer start event is non
// interrupting
assertEquals(1, taskQuery.count());
// check if execution still exists because timer start event is non
// interrupting
assertEquals(2, executionQuery.count());
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
assertEquals(1, processInstanceQuery.count());
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testStartTimerEventSubProcessInSubProcess.
@Deployment
public void testStartTimerEventSubProcessInSubProcess() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventSubProcessInSubProcess");
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(2, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// execute existing timer job
managementService.executeJob(managementService.createJobQuery().list().get(0).getId());
assertEquals(0, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
// check if user task doesn't exist because timer start event is
// interrupting
assertEquals(0, taskQuery.count());
// check if execution doesn't exist because timer start event is
// interrupting
assertEquals(0, executionQuery.count());
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
assertEquals(0, processInstanceQuery.count());
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testNonInterruptingStartTimerEventSubProcessInParallelMiSubProcessWithInterruptingBoundaryTimerEvent.
/**
* test scenario: - start process instance with multiInstance parallel -
* execute non interrupting timer job of event subprocess - execute
* interrupting timer boundary event of subprocess
*/
@Deployment
public void testNonInterruptingStartTimerEventSubProcessInParallelMiSubProcessWithInterruptingBoundaryTimerEvent() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
// execute multiInstance loop number 1
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(6, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery();
assertEquals(2, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(3, jobQuery.count());
// execute non interrupting timer job
managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(1).getId());
assertEquals(true, DummyServiceTask.wasExecuted);
// after non interrupting timer job execution
assertEquals(2, jobQuery.count());
assertEquals(2, taskQuery.count());
assertEquals(6, executionQuery.count());
// execute interrupting boundary timer job
managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(0).getId());
// after interrupting boundary timer job execution
assertEquals(0, jobQuery.count());
assertEquals(0, taskQuery.count());
assertEquals(0, executionQuery.count());
assertProcessEnded(processInstance.getId());
// start process instance again and
// test if boundary events deleted after all tasks are completed
processInstance = runtimeService.startProcessInstanceByKey("process");
jobQuery = managementService.createJobQuery();
assertEquals(3, jobQuery.count());
assertEquals(2, taskQuery.count());
// complete all existing tasks
for (Task task : taskQuery.list()) {
taskService.complete(task.getId());
}
assertEquals(0, jobQuery.count());
assertEquals(0, taskQuery.count());
assertEquals(0, executionQuery.count());
assertProcessEnded(processInstance.getId());
}
Aggregations