Search in sources :

Example 11 with CaseExecutionQuery

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

the class CaseServiceHumanTaskTest method testReenableAnDisabledHumanTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testReenableAnDisabledHumanTask() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
    // the human task is disabled
    caseService.withCaseExecution(caseExecutionId).disable();
    // when
    caseService.withCaseExecution(caseExecutionId).reenable();
    // then
    CaseExecution caseExecution = caseExecutionQuery.singleResult();
    // the human task is disabled
    assertFalse(caseExecution.isDisabled());
    assertFalse(caseExecution.isActive());
    assertTrue(caseExecution.isEnabled());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with CaseExecutionQuery

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

the class CaseServiceStageTest method testManualStartWithLocalVariable.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn" })
public void testManualStartWithLocalVariable() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    // an enabled child case execution of
    // the case instance
    String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
    // when
    // activate child case execution
    caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
    // then
    // the child case execution is active...
    CaseExecution caseExecution = caseExecutionQuery.singleResult();
    assertTrue(caseExecution.isActive());
    // ... and not enabled
    assertFalse(caseExecution.isEnabled());
    // (1) one case case execution representing "PI_HumanTask_1"
    verifyTasksState(caseExecutionQuery);
    // the case instance has two variables:
    // - aVariableName
    // - anotherVariableName
    List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
    verifyVariables(caseInstanceId, caseExecutionId, result);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with CaseExecutionQuery

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

the class CaseServiceStageTest method testReenableAnDisabledStage.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskAndOneStageWithManualActivationCase.cmmn" })
public void testReenableAnDisabledStage() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
    // the human task is disabled
    caseService.withCaseExecution(caseExecutionId).disable();
    // when
    caseService.withCaseExecution(caseExecutionId).reenable();
    // then
    CaseExecution caseExecution = caseExecutionQuery.singleResult();
    // the human task is disabled
    assertFalse(caseExecution.isDisabled());
    assertFalse(caseExecution.isActive());
    assertTrue(caseExecution.isEnabled());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with CaseExecutionQuery

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

the class CaseServiceStageTest method testDisableADisabledStage.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskAndOneStageWithManualActivationCase.cmmn" })
public void testDisableADisabledStage() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
    // the human task is disabled
    caseService.withCaseExecution(caseExecutionId).disable();
    try {
        // when
        caseService.withCaseExecution(caseExecutionId).disable();
        fail("It should not be possible to disable a already disabled human task.");
    } catch (NotAllowedException e) {
    }
}
Also used : NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with CaseExecutionQuery

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

the class CaseServiceStageTest method testManualWithVariables.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn" })
public void testManualWithVariables() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    // an enabled child case execution of
    // the case instance
    String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
    // variables
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("aVariableName", "abc");
    variables.put("anotherVariableName", 999);
    // when
    // activate child case execution
    caseService.withCaseExecution(caseExecutionId).setVariables(variables).manualStart();
    // then
    // the child case execution is active...
    CaseExecution caseExecution = caseExecutionQuery.singleResult();
    assertTrue(caseExecution.isActive());
    // ... and not enabled
    assertFalse(caseExecution.isEnabled());
    // (1) one case case execution representing "PI_HumanTask_1"
    verifyTasksState(caseExecutionQuery);
    // the case instance has two variables:
    // - aVariableName
    // - anotherVariableName
    List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
    verifyVariables(caseInstanceId, caseInstanceId, result);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) HashMap(java.util.HashMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) 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