use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testNonInterruptingStartTimerEventWithTwoEventSubProcesses.
@Deployment
public void testNonInterruptingStartTimerEventWithTwoEventSubProcesses() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingStartTimerEventWithTwoEventSubProcesses");
// 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(1, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
DummyServiceTask.wasExecuted = false;
// 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(1, executionQuery.count());
// execute second timer job
managementService.executeJob(orderedJobList.get(1).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 event is non interrupting
assertEquals(1, 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 testStartTimerEventSubProcessCalledFromCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/timer/simpleProcessWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/timer/StartTimerEventTest.testStartTimerEventWithTwoEventSubProcesses.bpmn20.xml" })
public void testStartTimerEventSubProcessCalledFromCallActivity() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("calledProcess", "startTimerEventWithTwoEventSubProcesses");
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("simpleCallActivityProcess", variables);
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(2, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery();
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 testStartTimerEventSubProcessInParallelMultiInstanceSubProcess.
@Deployment
public void testStartTimerEventSubProcessInParallelMultiInstanceSubProcess() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventSubProcessInParallelMultiInstanceSubProcess");
// 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(2, jobQuery.count());
// execute timer job
for (Job job : jobQuery.list()) {
managementService.executeJob(job.getId());
assertEquals(true, DummyServiceTask.wasExecuted);
DummyServiceTask.wasExecuted = false;
}
// 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 ExecutionAuthorizationTest method testSimpleQueryWithReadPermissionOnAnyProcessInstance.
public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
// when
ExecutionQuery query = runtimeService.createExecutionQuery();
// then
verifyQueryResults(query, 1);
Execution execution = query.singleResult();
assertNotNull(execution);
assertEquals(processInstanceId, execution.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class ExecutionAuthorizationTest method testSimpleQueryWithReadPermissionOnProcessInstance.
public void testSimpleQueryWithReadPermissionOnProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
// when
ExecutionQuery query = runtimeService.createExecutionQuery();
// then
verifyQueryResults(query, 1);
Execution execution = query.singleResult();
assertNotNull(execution);
assertEquals(processInstanceId, execution.getProcessInstanceId());
}
Aggregations