use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQuerySorting.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testQuerySorting() {
String taskId1 = "PI_HumanTask_1";
String taskId2 = "PI_HumanTask_2";
String oneTaskCaseId = createCaseInstanceByKey("oneTaskCase").getId();
String twoTaskCaseId = createCaseInstanceByKey("twoTaskCase").getId();
CaseExecution task1 = caseService.createCaseExecutionQuery().caseInstanceId(oneTaskCaseId).activityId(taskId1).singleResult();
CaseExecution task2 = caseService.createCaseExecutionQuery().caseInstanceId(twoTaskCaseId).activityId(taskId1).singleResult();
CaseExecution task3 = caseService.createCaseExecutionQuery().caseInstanceId(twoTaskCaseId).activityId(taskId2).singleResult();
// sort by historic case activity instance ids
assertQuerySorting("id", historicQuery().orderByHistoricCaseActivityInstanceId(), task1.getId(), task2.getId(), task3.getId());
// sort by case instance ids
assertQuerySorting("caseInstanceId", historicQuery().orderByCaseInstanceId(), oneTaskCaseId, twoTaskCaseId, twoTaskCaseId);
// sort by case execution ids
assertQuerySorting("caseExecutionId", historicQuery().orderByCaseExecutionId(), task1.getId(), task2.getId(), task3.getId());
// sort by case activity ids
assertQuerySorting("caseActivityId", historicQuery().orderByCaseActivityId(), taskId1, taskId1, taskId2);
// sort by case activity names
assertQuerySorting("caseActivityName", historicQuery().orderByCaseActivityName(), "A HumanTask", "A HumanTask", "Another HumanTask");
// sort by case definition ids
assertQuerySorting("caseDefinitionId", historicQuery().orderByCaseDefinitionId(), task1.getCaseDefinitionId(), task2.getCaseDefinitionId(), task3.getCaseDefinitionId());
// manually start tasks to be able to complete them
manualStart(task2.getId());
manualStart(task3.getId());
// complete tasks to set end time and duration
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery();
HistoricCaseActivityInstance historicTask1 = query.caseInstanceId(oneTaskCaseId).caseActivityId(taskId1).singleResult();
HistoricCaseActivityInstance historicTask2 = query.caseInstanceId(twoTaskCaseId).caseActivityId(taskId1).singleResult();
HistoricCaseActivityInstance historicTask3 = query.caseInstanceId(twoTaskCaseId).caseActivityId(taskId2).singleResult();
// sort by create times
assertQuerySorting("createTime", historicQuery().orderByHistoricCaseActivityInstanceCreateTime(), historicTask1.getCreateTime(), historicTask2.getCreateTime(), historicTask3.getCreateTime());
// sort by end times
assertQuerySorting("endTime", historicQuery().orderByHistoricCaseActivityInstanceEndTime(), historicTask1.getEndTime(), historicTask2.getEndTime(), historicTask3.getEndTime());
// sort by durations times
assertQuerySorting("durationInMillis", historicQuery().orderByHistoricCaseActivityInstanceDuration(), historicTask1.getDurationInMillis(), historicTask2.getDurationInMillis(), historicTask3.getDurationInMillis());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method assertHistoricEndTime.
protected void assertHistoricEndTime(String activityId, Date expectedEndTime) {
HistoricCaseActivityInstance historicActivityInstance = queryHistoricActivityCaseInstance(activityId);
Date actualEndTime = historicActivityInstance.getEndTime();
assertSimilarDate(expectedEndTime, actualEndTime);
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testMilestoneHistoricActivityInstanceIsTerminatedOnComplete.
@Deployment
public void testMilestoneHistoricActivityInstanceIsTerminatedOnComplete() {
// given
createCaseInstance();
final String milestoneId = "PI_Milestone_1";
CaseExecution caseMilestone = queryCaseExecutionByActivityId(milestoneId);
assertTrue(caseMilestone.isAvailable());
// when
CaseExecution casePlanExecution = queryCaseExecutionByActivityId("CasePlanModel_1");
complete(casePlanExecution.getId());
// then make sure that the milestone is terminated
HistoricCaseActivityInstance milestoneInstance = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId(milestoneId).singleResult();
assertTrue(milestoneInstance.isTerminated());
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricActivityInstancesAreMarkedTerminatedOnComplete.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageAndOneTaskCaseWithManualActivation.cmmn" })
public void testHistoricActivityInstancesAreMarkedTerminatedOnComplete() {
// given
createCaseInstance();
CaseExecution humanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
assertTrue(humanTask.isEnabled());
CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
assertTrue(stage.isEnabled());
// when
CaseExecution casePlanExecution = queryCaseExecutionByActivityId("CasePlanModel_1");
complete(casePlanExecution.getId());
// then make sure all cases in the lower scope are marked as terminated in history
HistoricCaseActivityInstance stageInstance = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_Stage_1").singleResult();
HistoricCaseActivityInstance taskInstance = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_3").singleResult();
assertTrue(stageInstance.isTerminated());
assertTrue(taskInstance.isTerminated());
}
Aggregations