Java Code Examples for org.camunda.bpm.engine.runtime.ProcessInstanceQuery#caseInstanceId()

The following examples show how to use org.camunda.bpm.engine.runtime.ProcessInstanceQuery#caseInstanceId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 2
Source File: ProcessInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryByInvalidCaseInstanceId() {
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();

  query.caseInstanceId("invalid");

  assertEquals(0, query.count());

  try {
    query.caseInstanceId(null);
    fail("The passed case instance should not be null.");
  } catch (Exception ignored) {}

}
 
Example 3
Source File: ProcessInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = {
    "org/camunda/bpm/engine/test/api/runtime/superCase.cmmn",
    "org/camunda/bpm/engine/test/api/runtime/superProcessWithCallActivityInsideSubProcess.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml"
  })
public void testQueryByCaseInstanceIdHierarchy() {
  String caseInstanceId = caseService
    .withCaseDefinitionByKey("oneProcessTaskCase")
    .businessKey("aBusinessKey")
    .create()
    .getId();

  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();

  query.caseInstanceId(caseInstanceId);

  assertEquals(2, query.count());

  List<ProcessInstance> result = query.list();
  assertEquals(2, result.size());

  ProcessInstance firstProcessInstance = result.get(0);
  assertEquals(caseInstanceId, firstProcessInstance.getCaseInstanceId());

  ProcessInstance secondProcessInstance = result.get(1);
  assertEquals(caseInstanceId, secondProcessInstance.getCaseInstanceId());
}