Search in sources :

Example 81 with CaseInstance

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

the class SentryScenario method newSentryInstance.

@DescribesScenario("newSentryInstance")
public static ScenarioSetup newSentryInstance() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, String scenarioName) {
            CaseService caseService = engine.getCaseService();
            CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
            String caseInstanceId = caseInstance.getId();
            CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);
            String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
            caseService.manuallyStartCaseExecution(firstHumanTaskId);
            caseService.completeCaseExecution(firstHumanTaskId);
            String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
            caseService.manuallyStartCaseExecution(secondHumanTaskId);
            caseService.completeCaseExecution(secondHumanTaskId);
        }
    };
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) CaseService(org.camunda.bpm.engine.CaseService) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario)

Example 82 with CaseInstance

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

the class SentryScenario method completeStage.

@DescribesScenario("triggerStageEntryCriterion")
public static ScenarioSetup completeStage() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, String scenarioName) {
            CaseService caseService = engine.getCaseService();
            CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
            String caseInstanceId = caseInstance.getId();
            CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);
            String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
            caseService.manuallyStartCaseExecution(firstHumanTaskId);
            caseService.completeCaseExecution(firstHumanTaskId);
            String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
            caseService.manuallyStartCaseExecution(secondHumanTaskId);
        }
    };
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) CaseService(org.camunda.bpm.engine.CaseService) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario)

Example 83 with CaseInstance

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

the class HistoricCaseActivityInstanceTest method testQueryByCaseInstanceIds.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceIds() {
    // given
    CaseInstance instance1 = createCaseInstance();
    CaseInstance instance2 = createCaseInstance();
    String taskInstanceId1 = caseService.createCaseExecutionQuery().caseInstanceId(instance1.getId()).activityId("PI_HumanTask_1").singleResult().getId();
    String taskInstanceId2 = caseService.createCaseExecutionQuery().caseInstanceId(instance2.getId()).activityId("PI_HumanTask_1").singleResult().getId();
    // when
    HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn(taskInstanceId1, taskInstanceId2);
    // then
    assertCount(2, query);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 84 with CaseInstance

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

the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityCalledCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testHistoricCaseActivityCalledCaseInstanceId() {
    String taskId = "PI_CaseTask_1";
    String calledCaseId = "oneTaskCase";
    String calledTaskId = "PI_HumanTask_1";
    createCaseInstanceByKey("oneCaseTaskCase").getId();
    // as long as the case task is not activated there should be no other case instance
    assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
    HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
    assertNull(historicInstance.getCalledCaseInstanceId());
    // start case task manually to create case instance
    CaseExecution caseTask = queryCaseExecutionByActivityId(taskId);
    manualStart(caseTask.getId());
    // there should exist a new case instance
    CaseInstance calledCaseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId).singleResult();
    assertNotNull(calledCaseInstance);
    // check that the called case instance id was correctly set
    historicInstance = queryHistoricActivityCaseInstance(taskId);
    assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
    // disable task to complete called case instance and close it
    CaseExecution calledTask = queryCaseExecutionByActivityId(calledTaskId);
    disable(calledTask.getId());
    close(calledCaseInstance.getId());
    // check that the called case instance id is still set
    assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
    historicInstance = queryHistoricActivityCaseInstance(taskId);
    assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) HistoricCaseActivityInstance(org.camunda.bpm.engine.history.HistoricCaseActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 85 with CaseInstance

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

the class HistoricCaseInstanceTest method testHistoricCaseInstanceQuery.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn", "org/camunda/bpm/engine/test/api/repository/three_.cmmn" })
public void testHistoricCaseInstanceQuery() {
    CaseInstance oneTaskCase = createCaseInstanceByKey("oneTaskCase", "oneBusiness");
    CaseInstance twoTaskCase = createCaseInstanceByKey("twoTaskCase", "twoBusiness");
    createCaseInstanceByKey("xyz_", "xyz_");
    assertCount(1, historicQuery().caseInstanceId(oneTaskCase.getId()));
    assertCount(1, historicQuery().caseInstanceId(twoTaskCase.getId()));
    Set<String> caseInstanceIds = new HashSet<String>();
    caseInstanceIds.add(oneTaskCase.getId());
    caseInstanceIds.add("unknown1");
    caseInstanceIds.add(twoTaskCase.getId());
    caseInstanceIds.add("unknown2");
    assertCount(2, historicQuery().caseInstanceIds(caseInstanceIds));
    assertCount(0, historicQuery().caseInstanceIds(caseInstanceIds).caseInstanceId("someOtherId"));
    assertCount(1, historicQuery().caseDefinitionId(oneTaskCase.getCaseDefinitionId()));
    assertCount(1, historicQuery().caseDefinitionKey("oneTaskCase"));
    assertCount(3, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("unknown")));
    assertCount(2, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")));
    assertCount(1, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase", "twoTaskCase")));
    assertCount(0, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")).caseDefinitionKey("oneTaskCase"));
    try {
        // oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
        historicQuery().caseDefinitionKeyNotIn(Arrays.asList(""));
        fail("Exception expected");
    } catch (NotValidException e) {
    // expected
    }
    assertCount(1, historicQuery().caseDefinitionName("One Task Case"));
    assertCount(2, historicQuery().caseDefinitionNameLike("%T%"));
    assertCount(1, historicQuery().caseDefinitionNameLike("One%"));
    assertCount(0, historicQuery().caseDefinitionNameLike("%Process%"));
    assertCount(1, historicQuery().caseDefinitionNameLike("%z\\_"));
    assertCount(1, historicQuery().caseInstanceBusinessKey("oneBusiness"));
    assertCount(2, historicQuery().caseInstanceBusinessKeyLike("%Business"));
    assertCount(1, historicQuery().caseInstanceBusinessKeyLike("one%"));
    assertCount(0, historicQuery().caseInstanceBusinessKeyLike("%unknown%"));
    assertCount(1, historicQuery().caseInstanceBusinessKeyLike("%z\\_"));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) NotValidException(org.camunda.bpm.engine.exception.NotValidException) 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