use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testParallelUserTasksHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelUserTasks.bpmn20.xml" })
public void testParallelUserTasksHistory() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().orderByTaskAssignee().asc().list();
for (int i = 0; i < historicTaskInstances.size(); i++) {
HistoricTaskInstance hi = historicTaskInstances.get(i);
assertNotNull(hi.getStartTime());
assertNotNull(hi.getEndTime());
assertEquals("kermit_" + i, hi.getAssignee());
}
HistoricActivityInstance multiInstanceBodyInstance = historyService.createHistoricActivityInstanceQuery().activityId("miTasks#multiInstanceBody").singleResult();
assertNotNull(multiInstanceBodyInstance);
assertEquals(pi.getId(), multiInstanceBodyInstance.getParentActivityInstanceId());
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(3, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
assertNotNull(hai.getAssignee());
assertEquals("userTask", hai.getActivityType());
assertEquals(multiInstanceBodyInstance.getId(), hai.getParentActivityInstanceId());
assertNotNull(hai.getTaskId());
}
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testSequentialUserTasksHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" })
public void testSequentialUserTasksHistory() {
runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap("nrOfLoops", 4)).getId();
for (int i = 0; i < 4; i++) {
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(4, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getActivityId());
assertNotNull(hai.getActivityName());
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
assertNotNull(hai.getAssignee());
}
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(4, historicTaskInstances.size());
for (HistoricTaskInstance ht : historicTaskInstances) {
assertNotNull(ht.getAssignee());
assertNotNull(ht.getStartTime());
assertNotNull(ht.getEndTime());
}
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskDurationReportTest method testHistoricTaskInstanceDurationReportResults.
@Test
public void testHistoricTaskInstanceDurationReportResults() {
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43);
DurationReportResult taskReportResult = historyService.createHistoricTaskInstanceReport().duration(PeriodUnit.MONTH).get(0);
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
long min = 0;
long max = 0;
long sum = 0;
for (int i = 0; i < historicTaskInstances.size(); i++) {
HistoricTaskInstance historicProcessInstance = historicTaskInstances.get(i);
Long duration = historicProcessInstance.getDurationInMillis();
sum = sum + duration;
max = i > 0 ? Math.max(max, duration) : duration;
min = i > 0 ? Math.min(min, duration) : duration;
}
long avg = sum / historicTaskInstances.size();
assertEquals("maximum", max, taskReportResult.getMaximum());
assertEquals("minimum", min, taskReportResult.getMinimum());
assertEquals("average", avg, taskReportResult.getAverage(), 0);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceId() {
// given
String key = "oneTaskCase";
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).singleResult().getId();
String caseInstanceId = caseService.withCaseDefinitionByKey(key).create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
HistoricTaskInstance task = query.singleResult();
assertNotNull(task);
assertEquals(caseDefinitionId, task.getCaseDefinitionId());
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertEquals(humanTaskId, task.getCaseExecutionId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseDefinitionName.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionName() {
// given
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
String caseDefinitionName = caseDefinition.getName();
String caseDefinitionId = caseDefinition.getId();
String caseInstanceId = caseService.withCaseDefinitionByKey("oneTaskCase").create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseDefinitionName(caseDefinitionName);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
HistoricTaskInstance task = query.singleResult();
assertNotNull(task);
assertEquals(caseDefinitionId, task.getCaseDefinitionId());
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertEquals(humanTaskId, task.getCaseExecutionId());
}
Aggregations