Search in sources :

Example 56 with CaseExecution

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

the class CaseInstanceQueryTest method testQueryByCompleted.

public void testQueryByCompleted() {
    for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
    repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn").deploy();
    for (int i = 0; i < 4; i++) {
        String id = caseService.withCaseDefinitionByKey(CASE_DEFINITION_KEY).businessKey(String.valueOf(i)).create().getId();
        caseInstanceIds.add(id);
    }
    List<CaseExecution> executions = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").list();
    for (CaseExecution caseExecution : executions) {
        caseService.withCaseExecution(caseExecution.getId()).disable();
    }
    CaseInstanceQuery query = caseService.createCaseInstanceQuery();
    query.completed();
    verifyQueryResults(query, 4);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Example 57 with CaseExecution

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

the class CaseExecutionQueryTest method testNullBusinessKeyForChildExecutions.

public void testNullBusinessKeyForChildExecutions() {
    caseService.createCaseInstanceByKey(CASE_DEFINITION_KEY, "7890");
    List<CaseExecution> executions = caseService.createCaseExecutionQuery().caseInstanceBusinessKey("7890").list();
    for (CaseExecution e : executions) {
        if (((CaseExecutionEntity) e).isCaseInstanceExecution()) {
            assertEquals("7890", ((CaseExecutionEntity) e).getBusinessKeyWithoutCascade());
        } else {
            assertNull(((CaseExecutionEntity) e).getBusinessKeyWithoutCascade());
        }
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution)

Example 58 with CaseExecution

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

the class CaseExecutionQueryTest method testQueryByCaseExecutionId.

public void testQueryByCaseExecutionId() {
    CaseExecutionQuery query = caseService.createCaseExecutionQuery();
    List<CaseExecution> executions = caseService.createCaseExecutionQuery().caseDefinitionKey(CASE_DEFINITION_KEY_2).list();
    for (CaseExecution execution : executions) {
        query.caseExecutionId(execution.getId());
        verifyQueryResults(query, 1);
    }
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery)

Example 59 with CaseExecution

use of org.camunda.bpm.engine.runtime.CaseExecution 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 60 with CaseExecution

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

the class SentryScenarioTest method testTriggerTaskEntryCriterion.

@Test
@ScenarioUnderTest("triggerTaskEntryCriterion.1")
public void testTriggerTaskEntryCriterion() {
    // given
    // enabled human task inside a stage instance
    String firstHumanTaskId = rule.caseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    // start and complete human task
    caseService.manuallyStartCaseExecution(firstHumanTaskId);
    caseService.completeCaseExecution(firstHumanTaskId);
    // then
    // entry criterion of the second human task inside the stage instance
    // will be triggered
    CaseExecution secondHumanTask = rule.caseExecutionQuery().activityId("PI_HumanTask_2").singleResult();
    // ... and the task is enabled
    assertTrue(secondHumanTask.isEnabled());
    CaseSentryPartEntity sentryPart = createCaseSentryPartQuery().sourceCaseExecutionId(firstHumanTaskId).singleResult();
    // the associated sentry part is not satisfied
    assertFalse(sentryPart.isSatisfied());
    // the source is null (because this sentry part
    // has been migrated into 7.4)
    assertNull(sentryPart.getSource());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseSentryPartEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseSentryPartEntity) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Aggregations

CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)280 Deployment (org.camunda.bpm.engine.test.Deployment)246 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)61 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)48 Task (org.camunda.bpm.engine.task.Task)28 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)27 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 Test (org.junit.Test)17 HashMap (java.util.HashMap)13 HistoricCaseActivityInstance (org.camunda.bpm.engine.history.HistoricCaseActivityInstance)11 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)11 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 VariableMap (org.camunda.bpm.engine.variable.VariableMap)7 DelegateCaseExecution (org.camunda.bpm.engine.delegate.DelegateCaseExecution)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)3 ArrayList (java.util.ArrayList)2 CaseService (org.camunda.bpm.engine.CaseService)2