Search in sources :

Example 96 with CaseExecution

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

the class SentryExitCriteriaTest method FAILING_testExitOnParentResumeInsideStage.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testExitOnParentResumeInsideStage.cmmn" })
public void FAILING_testExitOnParentResumeInsideStage() {
    // given
    createCaseInstance();
    CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
    String stageId = stage.getId();
    manualStart(stageId);
    CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
    String firstHumanTaskId = firstHumanTask.getId();
    assertTrue(firstHumanTask.isEnabled());
    CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
    String secondHumanTaskId = secondHumanTask.getId();
    assertTrue(secondHumanTask.isEnabled());
    // (1) when
    suspend(stageId);
    // (1) then
    stage = queryCaseExecutionById(stageId);
    assertTrue(((CaseExecutionEntity) stage).isSuspended());
    firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
    assertTrue(((CaseExecutionEntity) firstHumanTask).isSuspended());
    secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
    assertTrue(((CaseExecutionEntity) secondHumanTask).isSuspended());
    // (2) when
    resume(stageId);
    // (2) then
    stage = queryCaseExecutionById(stageId);
    assertTrue(((CaseExecutionEntity) stage).isActive());
    firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
    assertTrue(firstHumanTask.isEnabled());
    secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
    assertNull(secondHumanTask);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 97 with CaseExecution

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

the class SentryVariableOnPartEntryCriteriaTest method testSameVariableOnPartAsEntryAndExitCriteria.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/variableonpart/SentryVariableOnPartEntryCriteriaTest.testSameVariableOnPartAsEntryAndExitCriteria.cmmn" })
public void testSameVariableOnPartAsEntryAndExitCriteria() {
    caseService.createCaseInstanceByKey("Case_1").getId();
    CaseExecution stageExecution = queryCaseExecutionByActivityId("Stage_1");
    caseService.setVariable(stageExecution.getId(), "value", 99);
    CaseExecution humanTask = queryCaseExecutionByActivityId("HumanTask_1");
    // exit criteria not satisfied due to the variable 'value' must be greater than 100
    assertTrue(humanTask.isEnabled());
    manualStart(humanTask.getId());
    caseService.setVariable(stageExecution.getId(), "value", 101);
    stageExecution = queryCaseExecutionByActivityId("Stage_1");
    assertNull(stageExecution);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 98 with CaseExecution

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

the class SentryVariableOnPartEntryCriteriaTest method testNestedScopesWithNullVariableValue.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/variableonpart/SentryVariableOnPartEntryCriteriaTest.testSameVariableNameInDifferentScopes.cmmn" })
public void testNestedScopesWithNullVariableValue() {
    String caseInstanceId = caseService.createCaseInstanceByKey("Case_1").getId();
    String stageExecution1_Id = queryCaseExecutionByActivityId("Stage_1").getId();
    // set the variable 'value' in the scope of the case model
    caseService.setVariable(caseInstanceId, "value", 99);
    // set the variable 'value' in the scope of the stage 1 with null value
    caseService.setVariableLocal(stageExecution1_Id, "value", null);
    CaseExecution humanTask1 = queryCaseExecutionByActivityId("HumanTask_1");
    assertTrue(humanTask1.isAvailable());
    CaseExecution humanTask2 = queryCaseExecutionByActivityId("HumanTask_2");
    assertTrue(humanTask2.isAvailable());
    // update the variable 'value' in the case model scope
    caseService.setVariable(caseInstanceId, "value", 102);
    // then sentry of HumanTask 1 and HumanTask 2 gets evaluated.
    humanTask1 = queryCaseExecutionByActivityId("HumanTask_1");
    assertTrue(humanTask1.isEnabled());
    humanTask2 = queryCaseExecutionByActivityId("HumanTask_2");
    // Sentry attached to HumanTask 2 is not evaluated because a variable 'value' exists in stage 2 even if the value is null
    assertFalse(humanTask2.isEnabled());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 99 with CaseExecution

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

the class SentryVariableOnPartEntryCriteriaTest method testVariableDelete.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/variableonpart/SentryVariableOnPartEntryCriteriaTest.testVariableDelete.cmmn" })
public void testVariableDelete() {
    String caseInstanceId = caseService.createCaseInstanceByKey("Case_1").getId();
    caseService.removeVariable(caseInstanceId, "variable_1");
    CaseExecution firstHumanTask = queryCaseExecutionByActivityId("HumanTask_1");
    // removing unknown variable would not enable human task
    assertFalse(firstHumanTask.isEnabled());
    caseService.setVariable(caseInstanceId, "variable_1", "aVariable");
    firstHumanTask = queryCaseExecutionByActivityId("HumanTask_1");
    assertFalse(firstHumanTask.isEnabled());
    caseService.removeVariable(caseInstanceId, "variable_1");
    firstHumanTask = queryCaseExecutionByActivityId("HumanTask_1");
    assertTrue(firstHumanTask.isEnabled());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 100 with CaseExecution

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

the class SentryVariableOnPartEntryCriteriaTest method testMultipleSentryMultipleVariableOnParts.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/variableonpart/SentryVariableOnPartEntryCriteriaTest.testMultipleSentryMultipleVariableOnPart.cmmn" })
public void testMultipleSentryMultipleVariableOnParts() {
    String caseInstanceId = caseService.createCaseInstanceByKey("Case_1").getId();
    caseService.setVariable(caseInstanceId, "value", 99);
    CaseExecution firstHumanTask = queryCaseExecutionByActivityId("HumanTask_1");
    CaseExecution secondHumanTask = queryCaseExecutionByActivityId("HumanTask_2");
    // Sentry1 would not be satisfied as the value has to be > 100
    // Sentry2 would not be satisfied as the humanTask 1 has to completed
    assertFalse(secondHumanTask.isEnabled());
    manualStart(firstHumanTask.getId());
    complete(firstHumanTask.getId());
    secondHumanTask = queryCaseExecutionByActivityId("HumanTask_2");
    // Sentry1 would not be satisfied as the value has to be > 100
    // But, Sentry 2 would be satisfied and enables HumanTask2
    assertTrue(secondHumanTask.isEnabled());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

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