use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCompleteScope.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCompleteScope() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
completeProcessInstances();
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope();
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
// end
HistoricActivityStatistics end = statistics.get(0);
assertEquals("end", end.getId());
assertEquals(0, end.getInstances());
assertEquals(5, end.getCompleteScope());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testDifferentProcessesWithSameActivityId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testAnotherSingleTask.bpmn20.xml" })
public void testDifferentProcessesWithSameActivityId() {
String processDefinitionId = getProcessDefinitionId();
String anotherProcessDefinitionId = getProcessDefinitionIdByKey("anotherProcess");
startProcesses(5);
startProcessesByKey(10, "anotherProcess");
// first processDefinition
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
List<HistoricActivityStatistics> statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
HistoricActivityStatistics task = statistics.get(0);
assertEquals(5, task.getInstances());
// second processDefinition
query = historyService.createHistoricActivityStatisticsQuery(anotherProcessDefinitionId);
statistics = query.list();
assertEquals(1, query.count());
assertEquals(1, statistics.size());
task = statistics.get(0);
assertEquals(10, task.getInstances());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testQueryByCanceledAndFinished.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCanceledAndFinished() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(2);
// cancel running process instances
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
for (ProcessInstance processInstance : processInstances) {
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
startProcesses(2);
// complete running tasks
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
startProcesses(2);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().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(0, end.getCanceled());
assertEquals(2, end.getFinished());
// start
HistoricActivityStatistics start = statistics.get(1);
assertEquals("start", start.getId());
assertEquals(0, start.getInstances());
assertEquals(0, start.getCanceled());
assertEquals(6, start.getFinished());
// task
HistoricActivityStatistics task = statistics.get(2);
assertEquals("task", task.getId());
assertEquals(2, task.getInstances());
assertEquals(2, task.getCanceled());
assertEquals(4, task.getFinished());
}
use of org.camunda.bpm.engine.history.HistoricActivityStatistics in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsQueryTest method testFinishedProcessInstances.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testFinishedProcessInstances() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(5);
completeProcessInstances();
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 testQueryByCanceledAndCompleteScope.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByCanceledAndCompleteScope() {
String processDefinitionId = getProcessDefinitionId();
startProcesses(2);
// cancel running process instances
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
for (ProcessInstance processInstance : processInstances) {
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
startProcesses(2);
// complete running tasks
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
startProcesses(2);
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled().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(0, end.getCanceled());
assertEquals(2, end.getCompleteScope());
// task
HistoricActivityStatistics task = statistics.get(1);
assertEquals("task", task.getId());
assertEquals(2, task.getInstances());
assertEquals(2, task.getCanceled());
assertEquals(0, task.getCompleteScope());
}
Aggregations