use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCanceled.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCanceled() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
cancelProcessInstances();
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(0, task.getInstances());
assertEquals(5, task.getCanceled());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByFinishedAfterFinishingSomeInstances.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByFinishedAfterFinishingSomeInstances() {
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).includeFinished().orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(3, query.count());
assertEquals(3, statistics.size());
// end
HistoricActivityStatistics end = statistics.get(0);
assertEquals("end", end.getId());
assertEquals(0, end.getInstances());
assertEquals(2, end.getFinished());
// start
HistoricActivityStatistics start = statistics.get(1);
assertEquals("start", start.getId());
assertEquals(0, start.getInstances());
assertEquals(5, start.getFinished());
// task
HistoricActivityStatistics task = statistics.get(2);
assertEquals("task", task.getId());
assertEquals(3, task.getInstances());
assertEquals(2, task.getFinished());
completeProcessInstances();
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCompleteScopeMultipleRunningTasks.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testMultipleRunningTasks.bpmn20.xml")
public void testQueryByCompleteScopeMultipleRunningTasks() {
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).includeCompleteScope().orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(4, query.count());
assertEquals(4, statistics.size());
// end1
HistoricActivityStatistics end1 = statistics.get(0);
assertEquals("end1", end1.getId());
assertEquals(0, end1.getInstances());
assertEquals(5, end1.getCompleteScope());
// innerEnd
HistoricActivityStatistics innerEnd = statistics.get(1);
assertEquals("innerEnd", innerEnd.getId());
assertEquals(0, innerEnd.getInstances());
assertEquals(25, innerEnd.getCompleteScope());
// subprocess (completes the multi-instances body scope, see BPMN spec)
HistoricActivityStatistics subprocess = statistics.get(2);
assertEquals("subprocess", subprocess.getId());
assertEquals(0, subprocess.getInstances());
assertEquals(25, subprocess.getCompleteScope());
// task
HistoricActivityStatistics task = statistics.get(3);
assertEquals("task", task.getId());
assertEquals(5, 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 testMultipleRunningTasks.
@Deployment
public void testMultipleRunningTasks() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(4, query.count());
assertEquals(4, statistics.size());
// innerTask
HistoricActivityStatistics innerTask = statistics.get(0);
assertEquals("innerTask", innerTask.getId());
assertEquals(25, innerTask.getInstances());
// subprocess
HistoricActivityStatistics subProcess = statistics.get(1);
assertEquals("subprocess", subProcess.getId());
assertEquals(25, subProcess.getInstances());
// subprocess multi instance body
HistoricActivityStatistics subProcessMiBody = statistics.get(2);
assertEquals("subprocess#multiInstanceBody", subProcessMiBody.getId());
assertEquals(5, subProcessMiBody.getInstances());
// task
HistoricActivityStatistics task = statistics.get(3);
assertEquals("task", task.getId());
assertEquals(5, task.getInstances());
completeProcessInstances();
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testSingleTask.
@Deployment
public void testSingleTask() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
HistoricActivityStatistics statistic = statistics.get(0);
assertEquals("task", statistic.getId());
assertEquals(5, statistic.getInstances());
completeProcessInstances();
}
Aggregations