use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceQueryTest method testQueryBySubProcessInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryBySubProcessInstanceId() {
String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId();
String subProcessInstanceId = runtimeService.createProcessInstanceQuery().superCaseInstanceId(superCaseInstanceId).singleResult().getId();
CaseInstanceQuery query = caseService.createCaseInstanceQuery().subProcessInstanceId(subProcessInstanceId);
verifyQueryResults(query, 1);
CaseInstance caseInstance = query.singleResult();
assertEquals(superCaseInstanceId, caseInstance.getId());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseExecutionQueryTest method testQueryByCaseInstaceId.
public void testQueryByCaseInstaceId() {
CaseExecutionQuery query = caseService.createCaseExecutionQuery();
List<CaseInstance> caseInstances = caseService.createCaseInstanceQuery().caseDefinitionKey(CASE_DEFINITION_KEY).list();
for (CaseInstance caseInstance : caseInstances) {
query.caseInstanceId(caseInstance.getId());
verifyQueryResults(query, 2);
}
CaseInstance instance = caseService.createCaseInstanceQuery().caseDefinitionKey(CASE_DEFINITION_KEY_2).singleResult();
query.caseInstanceId(instance.getId());
verifyQueryResults(query, 3);
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testQueryResultOrderingByCaseInstanceVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testQueryResultOrderingByCaseInstanceVariables() {
// given three tasks with String case instance variables
CaseInstance instance1 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "cValue"));
CaseInstance instance2 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "aValue"));
CaseInstance instance3 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "bValue"));
// when I make a task query with ascending variable ordering by tasks variables
List<Task> tasks = taskService.createTaskQuery().caseDefinitionKey("oneTaskCase").orderByCaseInstanceVariable("var", ValueType.STRING).asc().list();
// then the tasks are ordered correctly by their local variables
assertEquals(3, tasks.size());
assertEquals(instance2.getId(), tasks.get(0).getCaseInstanceId());
assertEquals(instance3.getId(), tasks.get(1).getCaseInstanceId());
assertEquals(instance1.getId(), tasks.get(2).getCaseInstanceId());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testQueryResultOrderingByCaseExecutionVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn")
public void testQueryResultOrderingByCaseExecutionVariables() {
// given three tasks with String case instance variables
CaseInstance instance1 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "cValue"));
CaseInstance instance2 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "aValue"));
CaseInstance instance3 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "bValue"));
// and local case execution variables
CaseExecution caseExecution1 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").caseInstanceId(instance1.getId()).singleResult();
caseService.withCaseExecution(caseExecution1.getId()).setVariableLocal("var", "aValue").manualStart();
CaseExecution caseExecution2 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").caseInstanceId(instance2.getId()).singleResult();
caseService.withCaseExecution(caseExecution2.getId()).setVariableLocal("var", "bValue").manualStart();
CaseExecution caseExecution3 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").caseInstanceId(instance3.getId()).singleResult();
caseService.withCaseExecution(caseExecution3.getId()).setVariableLocal("var", "cValue").manualStart();
// when I make a task query with ascending variable ordering by tasks variables
List<Task> tasks = taskService.createTaskQuery().caseDefinitionKey("oneTaskCase").orderByCaseExecutionVariable("var", ValueType.STRING).asc().list();
// then the tasks are ordered correctly by their local variables
assertEquals(3, tasks.size());
assertEquals(instance1.getId(), tasks.get(0).getCaseInstanceId());
assertEquals(instance2.getId(), tasks.get(1).getCaseInstanceId());
assertEquals(instance3.getId(), tasks.get(2).getCaseInstanceId());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class TaskQueryOrTest method shouldReturnTasksWithCaseInstanceBusinessKeyOrCaseInstanceBusinessKeyLike.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase2.cmmn" })
public void shouldReturnTasksWithCaseInstanceBusinessKeyOrCaseInstanceBusinessKeyLike() {
// given
String caseDefinitionId1 = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").singleResult().getId();
CaseInstance caseInstance1 = caseService.withCaseDefinition(caseDefinitionId1).businessKey("aBusinessKey").create();
String caseDefinitionId2 = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase2").singleResult().getId();
CaseInstance caseInstance2 = caseService.withCaseDefinition(caseDefinitionId2).businessKey("anotherBusinessKey").create();
// when
List<Task> tasks = taskService.createTaskQuery().or().caseInstanceBusinessKey(caseInstance1.getBusinessKey()).caseInstanceBusinessKeyLike(caseInstance2.getBusinessKey()).endOr().list();
// then
assertEquals(2, tasks.size());
}
Aggregations