Search in sources :

Example 36 with HistoricActivityStatisticsQuery

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

Example 37 with HistoricActivityStatisticsQuery

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

Example 38 with HistoricActivityStatisticsQuery

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