Search in sources :

Example 31 with HistoricActivityStatisticsQuery

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

the class HistoricActivityStatisticsAuthorizationTest method testQueryWithReadHistoryPermissionOnProcessDefinition.

public void testQueryWithReadHistoryPermissionOnProcessDefinition() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(PROCESS_KEY).getId();
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    // when
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
    // then
    verifyQueryResults(query, 1);
    verifyStatisticsResult(query.singleResult(), 3, 0, 0, 0);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery)

Example 32 with HistoricActivityStatisticsQuery

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

the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingCanceledWithoutAuthorization.

// historic activity statistics query (including canceled) //////////////////////////////////
public void testQueryIncludingCanceledWithoutAuthorization() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(PROCESS_KEY).getId();
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    disableAuthorization();
    runtimeService.deleteProcessInstance(processInstanceId, null);
    enableAuthorization();
    // when
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled();
    // then
    verifyQueryResults(query, 0);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery)

Example 33 with HistoricActivityStatisticsQuery

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

the class HistoricActivityStatisticsQueryTest method testQueryByFinishedAndCompleteScopeAndCanceled.

@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByFinishedAndCompleteScopeAndCanceled() {
    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).includeFinished().includeCompleteScope().includeCanceled().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());
    assertEquals(2, end.getCompleteScope());
    // start
    HistoricActivityStatistics start = statistics.get(1);
    assertEquals("start", start.getId());
    assertEquals(0, start.getInstances());
    assertEquals(0, start.getCanceled());
    assertEquals(6, start.getFinished());
    assertEquals(0, start.getCompleteScope());
    // task
    HistoricActivityStatistics task = statistics.get(2);
    assertEquals("task", task.getId());
    assertEquals(2, task.getInstances());
    assertEquals(2, task.getCanceled());
    assertEquals(4, task.getFinished());
    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)

Example 34 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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 35 with HistoricActivityStatisticsQuery

use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery 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)

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