use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByActivityIdBeforeCompensation.
@Test
public void testQueryByActivityIdBeforeCompensation() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
// when
runtimeService.startProcessInstanceById(testProcess.getId());
testHelper.completeTask("userTask1");
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertNoProcessInstancesReturned(query);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByCaseInstanceId.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryByCaseInstanceId() {
String caseInstanceId = caseService.withCaseDefinitionByKey("oneProcessTaskCase").create().getId();
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(1, query.count());
List<ProcessInstance> result = query.list();
assertEquals(1, result.size());
ProcessInstance processInstance = result.get(0);
assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByActivityIdDuringCompensation.
@Test
public void testQueryByActivityIdDuringCompensation() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
// when
ProcessInstance processInstance = runtimeService.startProcessInstanceById(testProcess.getId());
testHelper.completeTask("userTask1");
testHelper.completeTask("userTask2");
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertReturnedProcessInstances(query, processInstance);
query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationEvent");
assertReturnedProcessInstances(query, processInstance);
query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationHandler");
assertReturnedProcessInstances(query, processInstance);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByAsyncAfterActivityId.
@Test
public void testQueryByAsyncAfterActivityId() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(ProcessModels.newModel().startEvent("start").camundaAsyncAfter().subProcess("subProcess").camundaAsyncAfter().embeddedSubProcess().startEvent().serviceTask("task").camundaAsyncAfter().camundaExpression("${true}").endEvent().subProcessDone().endEvent("end").camundaAsyncAfter().done());
// when
ProcessInstance instanceAfterStart = runtimeService.startProcessInstanceById(testProcess.getId());
ProcessInstance instanceAfterTask = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterTask);
ProcessInstance instanceAfterSubProcess = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterSubProcess);
executeJobForProcessInstance(instanceAfterSubProcess);
ProcessInstance instanceAfterEnd = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterEnd);
executeJobForProcessInstance(instanceAfterEnd);
executeJobForProcessInstance(instanceAfterEnd);
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("start");
assertReturnedProcessInstances(query, instanceAfterStart);
query = runtimeService.createProcessInstanceQuery().activityIdIn("task");
assertReturnedProcessInstances(query, instanceAfterTask);
query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertReturnedProcessInstances(query, instanceAfterSubProcess);
query = runtimeService.createProcessInstanceQuery().activityIdIn("end");
assertReturnedProcessInstances(query, instanceAfterEnd);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByNonLeafActivityId.
@Test
public void testQueryByNonLeafActivityId() {
// given
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(FORK_JOIN_SUB_PROCESS_MODEL);
// when
runtimeService.startProcessInstanceById(processDefinition.getId());
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess", "fork");
assertNoProcessInstancesReturned(query);
}
Aggregations