Search in sources :

Example 16 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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();
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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();
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 18 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.

the class HistoricActivityStatisticsQueryTest method testSorting.

@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testSorting() {
    String processDefinitionId = getProcessDefinitionId();
    startProcesses(5);
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
    assertEquals(1, query.orderByActivityId().asc().list().size());
    assertEquals(1, query.orderByActivityId().desc().list().size());
    assertEquals(1, query.orderByActivityId().asc().count());
    assertEquals(1, query.orderByActivityId().desc().count());
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 19 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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();
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) Task(org.camunda.bpm.engine.task.Task) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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();
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricActivityStatisticsQuery (org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery)38 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)29 Deployment (org.camunda.bpm.engine.test.Deployment)20 Task (org.camunda.bpm.engine.task.Task)9 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)6 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 DateConverter (org.camunda.bpm.engine.rest.dto.converter.DateConverter)1 HistoricActivityStatisticsDto (org.camunda.bpm.engine.rest.dto.history.HistoricActivityStatisticsDto)1