use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method testCompleteShouldCompleteCaseInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCase.cmmn" })
public void testCompleteShouldCompleteCaseInstance() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).create().getId();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_Stage_1").singleResult().getId();
// when
caseService.withCaseExecution(queryCaseExecutionByActivityId("PI_HumanTask_1").getId()).complete();
caseService.withCaseExecution(queryCaseExecutionByActivityId("PI_HumanTask_2").getId()).complete();
// then
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
// the case instance has been completed
CaseInstance caseInstance = caseService.createCaseInstanceQuery().completed().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isCompleted());
}
use of org.camunda.bpm.engine.runtime.CaseExecution 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);
}
use of org.camunda.bpm.engine.runtime.CaseExecution 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());
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method verifyTasksState.
protected void verifyTasksState(CaseExecutionQuery caseExecutionQuery) {
// (1) one case case execution representing "PI_HumanTask_1"
CaseExecution firstHumanTask = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult();
assertNotNull(firstHumanTask);
assertTrue(firstHumanTask.isActive());
assertFalse(firstHumanTask.isEnabled());
// (2) one case case execution representing "PI_HumanTask_2"
CaseExecution secondHumanTask = caseExecutionQuery.activityId("PI_HumanTask_2").singleResult();
assertNotNull(secondHumanTask);
assertTrue(secondHumanTask.isActive());
assertFalse(secondHumanTask.isEnabled());
}
use of org.camunda.bpm.engine.runtime.CaseExecution 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);
}
Aggregations