use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class StartTimerEventTest method testNonInterruptingStartTimerEventSubProcessInMultiInstanceSubProcessWithInterruptingBoundaryTimerEvent.
@Deployment
public void testNonInterruptingStartTimerEventSubProcessInMultiInstanceSubProcessWithInterruptingBoundaryTimerEvent() {
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(3, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery();
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
// 1 start timer job and 1 boundary timer job
assertEquals(2, jobQuery.count());
// execute non interrupting start timer event subprocess job
managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(1).getId());
assertEquals(true, DummyServiceTask.wasExecuted);
// complete user task to finish execution of first multiInstance loop
assertEquals(1, taskQuery.count());
taskService.complete(taskQuery.list().get(0).getId());
// after first non interrupting start timer event sub process execution
// multiInstance loop number 2
assertEquals(1, taskQuery.count());
assertEquals(2, jobQuery.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());
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 testNonInterruptingStartTimerEventSubProcessWithParallelMultiInstance.
@Deployment
public void testNonInterruptingStartTimerEventSubProcessWithParallelMultiInstance() {
DummyServiceTask.wasExecuted = false;
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingParallelMultiInstance");
// 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 all timer jobs
for (Job job : jobQuery.list()) {
managementService.executeJob(job.getId());
assertEquals(true, DummyServiceTask.wasExecuted);
DummyServiceTask.wasExecuted = false;
}
assertEquals(0, jobQuery.count());
// check if user task doesn't exist because timer start event is
// interrupting
assertEquals(2, taskQuery.count());
// check if execution doesn't exist because timer start event is
// interrupting
assertEquals(6, executionQuery.count());
// check if process instance doesn't exist because timer start event is
// interrupting
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 testNonInterruptingStartTimerEventSubProcessesCalledFromCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/timer/simpleProcessWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/timer/StartTimerEventTest.testNonInterruptingStartTimerEventWithTwoEventSubProcesses.bpmn20.xml" })
public void testNonInterruptingStartTimerEventSubProcessesCalledFromCallActivity() {
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 ProcessEngineRestServiceTest method createExecutionMock.
private void createExecutionMock() {
Execution mockExecution = MockProvider.createMockExecution();
ExecutionQuery mockExecutionQuery = mock(ExecutionQuery.class);
when(mockExecutionQuery.processInstanceId(eq(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID))).thenReturn(mockExecutionQuery);
when(mockExecutionQuery.singleResult()).thenReturn(mockExecution);
when(mockRuntimeService.createExecutionQuery()).thenReturn(mockExecutionQuery);
}
use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testGetSingleExecution.
@Test
public void testGetSingleExecution() {
Execution mockExecution = MockProvider.createMockExecution();
ExecutionQuery sampleExecutionQuery = mock(ExecutionQuery.class);
when(runtimeServiceMock.createExecutionQuery()).thenReturn(sampleExecutionQuery);
when(sampleExecutionQuery.executionId(MockProvider.EXAMPLE_EXECUTION_ID)).thenReturn(sampleExecutionQuery);
when(sampleExecutionQuery.singleResult()).thenReturn(mockExecution);
given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_EXECUTION_ID)).body("ended", equalTo(MockProvider.EXAMPLE_EXECUTION_IS_ENDED)).body("processInstanceId", equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(EXECUTION_URL);
}
Aggregations