use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricActivityInstanceWithinStageIsMarkedTerminatedOnComplete.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageAndOneTaskCaseWithManualActivation.cmmn" })
public void testHistoricActivityInstanceWithinStageIsMarkedTerminatedOnComplete() {
// given
createCaseInstance();
String stageExecutionId = queryCaseExecutionByActivityId("PI_Stage_1").getId();
manualStart(stageExecutionId);
String activeStageTaskExecutionId = queryCaseExecutionByActivityId("PI_HumanTask_Stage_2").getId();
complete(activeStageTaskExecutionId);
CaseExecution enabledStageTaskExecutionId = queryCaseExecutionByActivityId("PI_HumanTask_Stage_1");
assertTrue(enabledStageTaskExecutionId.isEnabled());
// when
complete(stageExecutionId);
// then the remaining stage task that was enabled is set to terminated in history
HistoricCaseActivityInstance manualActivationTask = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_Stage_1").singleResult();
HistoricCaseActivityInstance completedTask = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_Stage_2").singleResult();
assertTrue(manualActivationTask.isTerminated());
assertTrue(completedTask.isCompleted());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricTaskWithSentryIsMarkedTerminatedOnComplete.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageWithSentryAsEntryPointCase.cmmn" })
public void testHistoricTaskWithSentryIsMarkedTerminatedOnComplete() {
// given
createCaseInstance();
// when
CaseExecution casePlanExecution = queryCaseExecutionByActivityId("PI_Stage_1");
complete(casePlanExecution.getId());
// then both tasks are terminated
HistoricCaseActivityInstance taskInstance = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult();
HistoricCaseActivityInstance taskInstance2 = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_2").singleResult();
assertTrue(taskInstance.isTerminated());
assertTrue(taskInstance2.isTerminated());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityCalledCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testHistoricCaseActivityCalledCaseInstanceId() {
String taskId = "PI_CaseTask_1";
String calledCaseId = "oneTaskCase";
String calledTaskId = "PI_HumanTask_1";
createCaseInstanceByKey("oneCaseTaskCase").getId();
// as long as the case task is not activated there should be no other case instance
assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
assertNull(historicInstance.getCalledCaseInstanceId());
// start case task manually to create case instance
CaseExecution caseTask = queryCaseExecutionByActivityId(taskId);
manualStart(caseTask.getId());
// there should exist a new case instance
CaseInstance calledCaseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId).singleResult();
assertNotNull(calledCaseInstance);
// check that the called case instance id was correctly set
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
// disable task to complete called case instance and close it
CaseExecution calledTask = queryCaseExecutionByActivityId(calledTaskId);
disable(calledTask.getId());
close(calledCaseInstance.getId());
// check that the called case instance id is still set
assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityCalledProcessInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testHistoricCaseActivityCalledProcessInstanceId() {
String taskId = "PI_ProcessTask_1";
createCaseInstanceByKey("oneProcessTaskCase").getId();
// as long as the process task is not activated there should be no process instance
assertCount(0, runtimeService.createProcessInstanceQuery());
HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
assertNull(historicInstance.getCalledProcessInstanceId());
// start process task manually to create case instance
CaseExecution processTask = queryCaseExecutionByActivityId(taskId);
manualStart(processTask.getId());
// there should exist a new process instance
ProcessInstance calledProcessInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertNotNull(calledProcessInstance);
// check that the called process instance id was correctly set
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledProcessInstance.getId(), historicInstance.getCalledProcessInstanceId());
// complete task and thereby the process instance
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
// check that the task id is still set
assertCount(0, runtimeService.createProcessInstanceQuery());
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledProcessInstance.getId(), historicInstance.getCalledProcessInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityTaskId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testHistoricCaseActivityTaskId() {
String taskId = "PI_HumanTask_1";
createCaseInstance();
// as long as the human task was not started there should be no task id set
assertCount(0, taskService.createTaskQuery());
HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
assertNull(historicInstance.getTaskId());
// start human task manually to create task instance
CaseExecution humanTask = queryCaseExecutionByActivityId(taskId);
manualStart(humanTask.getId());
// there should exist a single task
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
// check that the task id was correctly set
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(task.getId(), historicInstance.getTaskId());
// complete task
taskService.complete(task.getId());
// check that the task id is still set
assertCount(0, taskService.createTaskQuery());
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(task.getId(), historicInstance.getTaskId());
}
Aggregations