Search in sources :

Example 26 with HistoricActivityStatistics

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

Example 27 with HistoricActivityStatistics

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

Example 28 with HistoricActivityStatistics

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());
}
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 29 with HistoricActivityStatistics

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

Example 30 with HistoricActivityStatistics

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());
}
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

HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)30 HistoricActivityStatisticsQuery (org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery)29 Deployment (org.camunda.bpm.engine.test.Deployment)19 Task (org.camunda.bpm.engine.task.Task)9 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)6 ArrayList (java.util.ArrayList)2 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