use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCompleteScopeAfterFinishingSomeInstances.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCompleteScopeAfterFinishingSomeInstances() {
String processDefinitionId = getProcessDefinitionId();
// start five instances
startProcesses(5);
// complete two task, so that two process instances are finished
List<Task> tasks = taskService.createTaskQuery().list();
for (int i = 0; i < 2; i++) {
taskService.complete(tasks.get(i).getId());
}
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope().orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(2, query.count());
assertEquals(2, statistics.size());
// end
HistoricActivityStatistics end = statistics.get(0);
assertEquals("end", end.getId());
assertEquals(0, end.getInstances());
assertEquals(2, end.getCompleteScope());
// task
HistoricActivityStatistics task = statistics.get(1);
assertEquals("task", task.getId());
assertEquals(3, task.getInstances());
assertEquals(0, task.getCompleteScope());
completeProcessInstances();
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCanceledAfterCancelingSomeInstances.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCanceledAfterCancelingSomeInstances() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(3);
// cancel running process instances
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
for (ProcessInstance processInstance : processInstances) {
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
startProcesses(2);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
// task
HistoricActivityStatistics task = statistics.get(0);
assertEquals("task", task.getId());
assertEquals(2, task.getInstances());
assertEquals(3, task.getCanceled());
completeProcessInstances();
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testNoRunningProcessInstances.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testNoRunningProcessInstances() {
String processDefinitionId = getProcessDefinitionId();
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(0, query.count());
assertEquals(0, statistics.size());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCanceledAndFinishedByPeriods.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCanceledAndFinishedByPeriods() throws ParseException {
try {
// start two process instances
ClockUtil.setCurrentTime(sdf.parse("15.01.2016 12:00:00"));
startProcesses(2);
// cancel running process instances
ClockUtil.setCurrentTime(sdf.parse("15.02.2016 12:00:00"));
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
for (ProcessInstance processInstance : processInstances) {
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
// start two process instances
ClockUtil.setCurrentTime(sdf.parse("01.02.2016 12:00:00"));
startProcesses(2);
// complete running tasks
ClockUtil.setCurrentTime(sdf.parse("25.02.2016 12:00:00"));
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
// starte two more process instances
ClockUtil.setCurrentTime(sdf.parse("15.03.2016 12:00:00"));
startProcesses(2);
// NOW
ClockUtil.setCurrentTime(sdf.parse("25.03.2016 12:00:00"));
String processDefinitionId = getProcessDefinitionId();
// check January by started dates
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.01.2016 00:00:00")).startedBefore(sdf.parse("31.01.2016 23:59:59")).orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(2, query.count());
assertEquals(2, statistics.size());
// start
assertActivityStatistics(statistics.get(0), "start", 0, 0, 2);
// task
assertActivityStatistics(statistics.get(1), "task", 0, 2, 2);
// check January by finished dates
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.01.2016 00:00:00")).finishedBefore(sdf.parse("31.01.2016 23:59:59")).orderByActivityId().asc();
statistics = query.list();
assertEquals(0, query.count());
assertEquals(0, statistics.size());
// check February by started dates
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.02.2016 00:00:00")).startedBefore(sdf.parse("28.02.2016 23:59:59")).orderByActivityId().asc();
statistics = query.list();
assertEquals(3, query.count());
assertEquals(3, statistics.size());
// end
assertActivityStatistics(statistics.get(0), "end", 0, 0, 2);
// start
assertActivityStatistics(statistics.get(1), "start", 0, 0, 2);
// task
assertActivityStatistics(statistics.get(2), "task", 0, 0, 2);
// check February by finished dates
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.02.2016 00:00:00")).finishedBefore(sdf.parse("28.02.2016 23:59:59")).orderByActivityId().asc();
statistics = query.list();
assertEquals(3, query.count());
assertEquals(3, statistics.size());
// end
assertActivityStatistics(statistics.get(0), "end", 0, 0, 2);
// start
assertActivityStatistics(statistics.get(1), "start", 0, 0, 4);
// task
assertActivityStatistics(statistics.get(2), "task", 0, 2, 4);
// check March by started dates
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.03.2016 00:00:00")).orderByActivityId().asc();
statistics = query.list();
assertEquals(2, query.count());
assertEquals(2, statistics.size());
// start
assertActivityStatistics(statistics.get(0), "start", 0, 0, 2);
// task
assertActivityStatistics(statistics.get(1), "task", 2, 0, 0);
// check March by finished dates
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().finishedAfter(sdf.parse("01.03.2016 00:00:00")).orderByActivityId().asc();
statistics = query.list();
assertEquals(0, query.count());
assertEquals(0, statistics.size());
// check whole period by started date
query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().includeFinished().startedAfter(sdf.parse("01.01.2016 00:00:00")).orderByActivityId().asc();
statistics = query.list();
assertEquals(3, query.count());
assertEquals(3, statistics.size());
// end
assertActivityStatistics(statistics.get(0), "end", 0, 0, 2);
// start
assertActivityStatistics(statistics.get(1), "start", 0, 0, 6);
// task
assertActivityStatistics(statistics.get(2), "task", 2, 2, 4);
} finally {
ClockUtil.reset();
}
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByFinishedMultipleRunningTasks.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testMultipleRunningTasks.bpmn20.xml")
public void testQueryByFinishedMultipleRunningTasks() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
List<Task> tasks = taskService.createTaskQuery().taskDefinitionKey("innerTask").list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(9, query.count());
assertEquals(9, statistics.size());
// end1
HistoricActivityStatistics end1 = statistics.get(0);
assertEquals("end1", end1.getId());
assertEquals(0, end1.getInstances());
assertEquals(5, end1.getFinished());
// gtw
HistoricActivityStatistics gtw = statistics.get(1);
assertEquals("gtw", gtw.getId());
assertEquals(0, gtw.getInstances());
assertEquals(5, gtw.getFinished());
// innerEnd
HistoricActivityStatistics innerEnd = statistics.get(2);
assertEquals("innerEnd", innerEnd.getId());
assertEquals(0, innerEnd.getInstances());
assertEquals(25, innerEnd.getFinished());
// innerStart
HistoricActivityStatistics innerStart = statistics.get(3);
assertEquals("innerStart", innerStart.getId());
assertEquals(0, innerStart.getInstances());
assertEquals(25, innerStart.getFinished());
// innerTask
HistoricActivityStatistics innerTask = statistics.get(4);
assertEquals("innerTask", innerTask.getId());
assertEquals(0, innerTask.getInstances());
assertEquals(25, innerTask.getFinished());
// innerStart
HistoricActivityStatistics start = statistics.get(5);
assertEquals("start", start.getId());
assertEquals(0, start.getInstances());
assertEquals(5, start.getFinished());
// subprocess
HistoricActivityStatistics subProcess = statistics.get(6);
assertEquals("subprocess", subProcess.getId());
assertEquals(0, subProcess.getInstances());
assertEquals(25, subProcess.getFinished());
// subprocess - multi-instance body
HistoricActivityStatistics subProcessMiBody = statistics.get(7);
assertEquals("subprocess#multiInstanceBody", subProcessMiBody.getId());
assertEquals(0, subProcessMiBody.getInstances());
assertEquals(5, subProcessMiBody.getFinished());
// task
HistoricActivityStatistics task = statistics.get(8);
assertEquals("task", task.getId());
assertEquals(5, task.getInstances());
assertEquals(0, task.getFinished());
completeProcessInstances();
}
Aggregations