Search in sources :

Example 91 with CaseExecutionQuery

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

the class RepetitionRuleTest method testRepeatStageMultipleTimes.

@Deployment
public void testRepeatStageMultipleTimes() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when (1)
    disable(firstHumanTaskId);
    // then (1)
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(2, query.count());
    CaseExecution originInstance = query.active().singleResult();
    assertNotNull(originInstance);
    CaseExecution repetitionInstance = query.available().singleResult();
    assertNotNull(repetitionInstance);
    // when (2)
    reenable(firstHumanTaskId);
    disable(firstHumanTaskId);
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(3, query.count());
    // enabled instances
    assertEquals(2, query.active().count());
    // available instances
    assertEquals(1, query.available().count());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 92 with CaseExecutionQuery

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

the class RepetitionRuleTest method testRepeatStageWithoutEntryCriteriaOnCustomStandardEvent.

@Deployment
public void testRepeatStageWithoutEntryCriteriaOnCustomStandardEvent() {
    // given
    String caseInstanceId = createCaseInstance().getId();
    CaseExecutionQuery stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(1, stageQuery.count());
    CaseExecution enabledStageCaseExecution = stageQuery.enabled().singleResult();
    assertNotNull(enabledStageCaseExecution);
    // when (1)
    disable(enabledStageCaseExecution.getId());
    // then (1)
    stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(2, stageQuery.count());
    enabledStageCaseExecution = stageQuery.enabled().singleResult();
    assertNotNull(enabledStageCaseExecution);
    // when (2)
    disable(enabledStageCaseExecution.getId());
    // then (2)
    stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(3, stageQuery.count());
    enabledStageCaseExecution = stageQuery.enabled().singleResult();
    assertNotNull(enabledStageCaseExecution);
    // when (3)
    complete(caseInstanceId);
    // then (3)
    CaseExecutionQuery query = caseService.createCaseExecutionQuery();
    assertEquals(1, query.count());
    assertEquals(caseInstanceId, query.singleResult().getId());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 93 with CaseExecutionQuery

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

the class RepetitionRuleTest method testRepeatStage.

@Deployment
public void testRepeatStage() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when
    complete(firstHumanTaskId);
    // then
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(2, query.count());
    CaseExecution originInstance = query.active().singleResult();
    assertNotNull(originInstance);
    CaseExecution repetitionInstance = query.available().singleResult();
    assertNotNull(repetitionInstance);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 94 with CaseExecutionQuery

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

the class RepetitionRuleTest method testDefaultVariableBasedRepetitionRuleEvaluatesToFalse.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/repetition/RepetitionRuleTest.testDefaultVariableBasedRule.cmmn")
public void testDefaultVariableBasedRepetitionRuleEvaluatesToFalse() {
    // given
    VariableMap variables = Variables.createVariables().putValue("repeat", false);
    createCaseInstanceByKey("case", variables);
    String humanTask1 = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when
    complete(humanTask1);
    // then
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2");
    assertEquals(1, query.count());
    assertEquals(1, query.active().count());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 95 with CaseExecutionQuery

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

the class RepetitionRuleTest method testRepeatTaskWithoutEntryCriteriaWhenCompleting.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/repetition/RepetitionRuleTest.testRepeatTaskWithoutEntryCriteria.cmmn")
public void testRepeatTaskWithoutEntryCriteriaWhenCompleting() {
    // given
    String caseInstanceId = createCaseInstanceByKey(CASE_ID, Variables.createVariables().putValue("repeating", true)).getId();
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(1, query.count());
    CaseExecution activeCaseExecution = query.active().singleResult();
    assertNotNull(activeCaseExecution);
    // when (1)
    complete(activeCaseExecution.getId());
    // then (1)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(1, query.count());
    activeCaseExecution = query.active().singleResult();
    assertNotNull(activeCaseExecution);
    // when (2)
    caseService.setVariable(caseInstanceId, "repeating", false);
    complete(activeCaseExecution.getId());
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(0, query.count());
    // then (3)
    query = caseService.createCaseExecutionQuery();
    assertEquals(1, query.count());
    assertEquals(caseInstanceId, query.singleResult().getId());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)226 Deployment (org.camunda.bpm.engine.test.Deployment)70 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)47 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)24 NotValidException (org.camunda.bpm.engine.exception.NotValidException)24 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)16 ArrayList (java.util.ArrayList)14 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)13 Date (java.util.Date)12 Task (org.camunda.bpm.engine.task.Task)10 VariableMap (org.camunda.bpm.engine.variable.VariableMap)9 HashMap (java.util.HashMap)8 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)4 CaseService (org.camunda.bpm.engine.CaseService)2 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)2 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)2 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 CaseExecutionDto (org.camunda.bpm.engine.rest.dto.runtime.CaseExecutionDto)1