use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testMultipleProcessDefinitions.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.calledProcess.bpmn20.xml" })
public void testMultipleProcessDefinitions() {
String processId = getProcessDefinitionId();
String calledProcessId = getProcessDefinitionIdByKey("calledProcess");
startProcesses(5);
startProcessesByKey(10, "calledProcess");
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processId).orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
// callActivity
HistoricActivityStatistics calledActivity = statistics.get(0);
assertEquals("callActivity", calledActivity.getId());
assertEquals(5, calledActivity.getInstances());
query = historyService.createHistoricActivityStatisticsQuery(calledProcessId).orderByActivityId().asc();
statistics = query.list();
assertEquals(2, query.count());
assertEquals(2, statistics.size());
// task1
HistoricActivityStatistics task1 = statistics.get(0);
assertEquals("task1", task1.getId());
assertEquals(15, task1.getInstances());
// task2
HistoricActivityStatistics task2 = statistics.get(1);
assertEquals("task2", task2.getId());
assertEquals(15, task2.getInstances());
completeProcessInstances();
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByFinished.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByFinished() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(2, query.count());
assertEquals(2, statistics.size());
// start
HistoricActivityStatistics start = statistics.get(0);
assertEquals("start", start.getId());
assertEquals(0, start.getInstances());
assertEquals(5, start.getFinished());
// task
HistoricActivityStatistics task = statistics.get(1);
assertEquals("task", task.getId());
assertEquals(5, task.getInstances());
assertEquals(0, task.getFinished());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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.HistoricActivityStatisticsQuery 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.HistoricActivityStatisticsQuery 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();
}
Aggregations