use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceProcessTaskTest method testTerminate.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTerminate() {
// given
createCaseInstance(DEFINITION_KEY);
CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
assertTrue(processTask.isActive());
// when
caseService.withCaseExecution(processTask.getId()).terminate();
processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
assertNull(processTask);
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceProcessTaskTest method testTerminateNonActiveProcessTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTerminateNonActiveProcessTask() {
// given
createCaseInstance(DEFINITION_KEY);
CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
assertTrue(processTask.isEnabled());
try {
// when
caseService.terminateCaseExecution(processTask.getId());
fail("It should not be possible to terminate a task.");
} catch (NotAllowedException e) {
boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate");
assertTrue(result);
}
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceProcessTaskTest method testManualStart.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testManualStart() {
// given
String caseInstanceId = createCaseInstance(DEFINITION_KEY).getId();
String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK_KEY).getId();
ProcessInstance processInstance = queryProcessInstance();
assertNull(processInstance);
// when
caseService.withCaseExecution(processTaskId).manualStart();
// then
processInstance = queryProcessInstance();
assertNotNull(processInstance);
assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
assertTrue(processTask.isActive());
}
use of org.camunda.bpm.engine.runtime.CaseExecution 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());
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method testTerminateNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCase.cmmn" })
public void testTerminateNonFluent() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecution stageExecution = queryCaseExecutionByActivityId("PI_Stage_1");
// when
caseService.terminateCaseExecution(stageExecution.getId());
// then
stageExecution = queryCaseExecutionByActivityId("PI_Stage_1");
assertNull(stageExecution);
}
Aggregations