Search in sources :

Example 41 with CaseInstance

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());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 42 with CaseInstance

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);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery)

Example 43 with CaseInstance

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());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Task(org.camunda.bpm.engine.task.Task) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 44 with CaseInstance

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());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 45 with CaseInstance

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());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)183 Deployment (org.camunda.bpm.engine.test.Deployment)149 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)62 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)23 Test (org.junit.Test)21 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)18 Task (org.camunda.bpm.engine.task.Task)18 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)16 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)13 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)10 HashMap (java.util.HashMap)9 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)9 ArrayList (java.util.ArrayList)6 CaseService (org.camunda.bpm.engine.CaseService)6 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)6 Date (java.util.Date)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)5 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 VariableMap (org.camunda.bpm.engine.variable.VariableMap)5