Search in sources :

Example 76 with CaseInstanceQuery

use of org.camunda.bpm.engine.runtime.CaseInstanceQuery in project camunda-bpm-platform by camunda.

the class AutoCompleteTest method testManualActivationDisabled.

@Deployment
public void testManualActivationDisabled() {
    // given
    // a deployed case definition
    // when (1)
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    // then (1)
    CaseInstanceQuery instanceQuery = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId);
    CaseInstance caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    // when (2)
    caseService.completeCaseExecution(humanTask2Id);
    // then (2)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
    // humanTask1 and humanTask2 are not available
    assertNull(executionQuery.activityId("PI_HumanTask_1").singleResult());
    assertNull(executionQuery.activityId("PI_HumanTask_2").singleResult());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 77 with CaseInstanceQuery

use of org.camunda.bpm.engine.runtime.CaseInstanceQuery in project camunda-bpm-platform by camunda.

the class AutoCompleteTest method testRequiredEnabled.

@Deployment
public void testRequiredEnabled() {
    // given
    // a deployed case definition
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    CaseInstanceQuery instanceQuery = caseService.createCaseInstanceQuery();
    // when (1)
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    // then (1)
    CaseInstance caseInstance = instanceQuery.caseInstanceId(caseInstanceId).singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    String humanTask1Id = executionQuery.activityId("PI_HumanTask_1").singleResult().getId();
    manualStart(humanTask1Id);
    // when (2)
    complete(humanTask1Id);
    // then (2)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    manualStart(humanTask2Id);
    // when (3)
    complete(humanTask2Id);
    // then (3)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 78 with CaseInstanceQuery

use of org.camunda.bpm.engine.runtime.CaseInstanceQuery in project camunda-bpm-platform by camunda.

the class AutoCompleteTest method testTerminate.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/stage/AutoCompleteTest.testRequiredEnabled.cmmn" })
public void testTerminate() {
    // given
    // a deployed case definition
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    CaseInstanceQuery instanceQuery = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId);
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    manualStart(humanTask2Id);
    // when
    terminate(humanTask2Id);
    // then
    CaseInstance caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 79 with CaseInstanceQuery

use of org.camunda.bpm.engine.runtime.CaseInstanceQuery in project camunda-bpm-platform by camunda.

the class CaseInstanceRestServiceImpl method queryCaseInstancesCount.

public CountResultDto queryCaseInstancesCount(CaseInstanceQueryDto queryDto) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    CaseInstanceQuery query = queryDto.toQuery(engine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 80 with CaseInstanceQuery

use of org.camunda.bpm.engine.runtime.CaseInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyCallActivityTest method testCaseRefTenantIdExpression.

public void testCaseRefTenantIdExpression() {
    BpmnModelInstance callingProcess = Bpmn.createExecutableProcess("callingProcess").startEvent().callActivity().camundaCaseRef("Case_1").camundaCaseTenantId("${'" + TENANT_ONE + "'}").endEvent().done();
    deploymentForTenant(TENANT_ONE, CMMN);
    deployment(callingProcess);
    runtimeService.startProcessInstanceByKey("callingProcess");
    CaseInstanceQuery query = caseService.createCaseInstanceQuery().caseDefinitionKey("Case_1");
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Aggregations

CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)123 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)21 Deployment (org.camunda.bpm.engine.test.Deployment)10 NotValidException (org.camunda.bpm.engine.exception.NotValidException)9 ArrayList (java.util.ArrayList)8 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)7 Date (java.util.Date)6 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)4 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 CaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1