use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQueryByInvalidCaseActivityId.
public void testQueryByInvalidCaseActivityId() {
// when
HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityIdIn("invalid");
// then
assertCount(0, query);
try {
historicQuery().caseActivityIdIn((String[]) null);
fail("A NotValidException was expected.");
} catch (NotValidException e) {
}
try {
historicQuery().caseActivityIdIn((String) null);
fail("A NotValidException was expected.");
} catch (NotValidException e) {
}
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQueryByInvalidCaseInstanceId.
public void testQueryByInvalidCaseInstanceId() {
// when
HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn("invalid");
// then
assertCount(0, query);
try {
historicQuery().caseActivityInstanceIdIn((String[]) null);
fail("A NotValidException was expected.");
} catch (NotValidException e) {
}
try {
historicQuery().caseActivityInstanceIdIn((String) null);
fail("A NotValidException was expected.");
} catch (NotValidException e) {
}
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQueryByCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceId() {
// given
createCaseInstance();
String taskInstanceId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
// when
HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn(taskInstanceId);
// then
assertCount(1, query);
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery 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.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQueryByCaseActivityIds.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testQueryByCaseActivityIds() {
// given
createCaseInstanceByKey("oneTaskCase");
createCaseInstanceByKey("twoTaskCase");
// when
HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityIdIn("PI_HumanTask_1", "PI_HumanTask_2");
// then
assertCount(3, query);
}
Aggregations