use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testCompleteWithRemoveVariableLocal.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithRemoveVariableLocal() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).create();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
// when
caseService.withCaseExecution(caseExecutionId).removeVariableLocal("aVariableName").removeVariableLocal("anotherVariableName").complete();
// then
// the task has been completed and has been deleted
task = taskService.createTaskQuery().singleResult();
assertNull(task);
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
// the case instance is still active
CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isActive());
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertTrue(result.isEmpty());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testCompleteWithSetVariableLocal.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithSetVariableLocal() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).create();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
caseService.withCaseExecution(caseExecutionId).manualStart();
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
// when
caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).complete();
// then
// the task has been completed and has been deleted
task = taskService.createTaskQuery().singleResult();
assertNull(task);
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
// the case instance is still active
CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isActive());
// the variables has been set and due to the completion
// also removed in one command
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertTrue(result.isEmpty());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testCompleteNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteNonFluent() {
// 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_HumanTask_1").singleResult().getId();
caseService.withCaseExecution(caseExecutionId).manualStart();
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
// when
caseService.completeCaseExecution(caseExecutionId);
// then
// the task has been completed and has been deleted
task = taskService.createTaskQuery().singleResult();
assertNull(task);
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
// the case instance is still active
CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isActive());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testDisableShouldCompleteCaseInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testDisableShouldCompleteCaseInstance() {
// 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_HumanTask_1").singleResult().getId();
// when
caseService.withCaseExecution(caseExecutionId).disable();
// 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.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method testComplete.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskAndOneStageCase.cmmn" })
public void testComplete() {
// 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_11").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_Stage_1").singleResult();
assertNull(caseExecution);
// the case instance is still active
CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isActive());
}
Aggregations