Search in sources :

Example 6 with HistoricActivityStatistics

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

the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingFinishedWithReadHistoryPermissionOnProcessDefinition.

public void testQueryIncludingFinishedWithReadHistoryPermissionOnProcessDefinition() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(PROCESS_KEY).getId();
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectAnyTask().getId();
    disableAuthorization();
    taskService.complete(taskId);
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    // when
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished();
    // then
    verifyQueryResults(query, 3);
    List<HistoricActivityStatistics> statistics = query.list();
    HistoricActivityStatistics start = getStatisticsByKey(statistics, "theStart");
    verifyStatisticsResult(start, 0, 3, 0, 0);
    HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
    verifyStatisticsResult(task, 2, 1, 0, 0);
    HistoricActivityStatistics end = getStatisticsByKey(statistics, "theEnd");
    verifyStatisticsResult(end, 0, 1, 0, 0);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 7 with HistoricActivityStatistics

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

the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingAllWithReadHistoryPermissionOnAnyProcessDefinition.

public void testQueryIncludingAllWithReadHistoryPermissionOnAnyProcessDefinition() {
    // 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();
    String taskId = selectAnyTask().getId();
    disableAuthorization();
    taskService.complete(taskId);
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().includeCanceled().includeCompleteScope();
    // then
    verifyQueryResults(query, 3);
    List<HistoricActivityStatistics> statistics = query.list();
    HistoricActivityStatistics start = getStatisticsByKey(statistics, "theStart");
    verifyStatisticsResult(start, 0, 3, 0, 0);
    HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
    verifyStatisticsResult(task, 1, 2, 1, 0);
    HistoricActivityStatistics end = getStatisticsByKey(statistics, "theEnd");
    verifyStatisticsResult(end, 0, 1, 0, 1);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 8 with HistoricActivityStatistics

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

the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingAllWithReadHistoryPermissionOnProcessDefinition.

public void testQueryIncludingAllWithReadHistoryPermissionOnProcessDefinition() {
    // 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();
    String taskId = selectAnyTask().getId();
    disableAuthorization();
    taskService.complete(taskId);
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    // when
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().includeCanceled().includeCompleteScope();
    // then
    verifyQueryResults(query, 3);
    List<HistoricActivityStatistics> statistics = query.list();
    HistoricActivityStatistics start = getStatisticsByKey(statistics, "theStart");
    verifyStatisticsResult(start, 0, 3, 0, 0);
    HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
    verifyStatisticsResult(task, 1, 2, 1, 0);
    HistoricActivityStatistics end = getStatisticsByKey(statistics, "theEnd");
    verifyStatisticsResult(end, 0, 1, 0, 1);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 9 with HistoricActivityStatistics

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

the class HistoricActivityStatisticsQueryTest method testMultipleProcessDefinitions.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.calledProcess.bpmn20.xml" })
public void testMultipleProcessDefinitions() {
    String processId = getProcessDefinitionId();
    String calledProcessId = getProcessDefinitionIdByKey("calledProcess");
    startProcesses(5);
    startProcessesByKey(10, "calledProcess");
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processId).orderByActivityId().asc();
    List<HistoricActivityStatistics> statistics = query.list();
    assertEquals(1, query.count());
    assertEquals(1, statistics.size());
    // callActivity
    HistoricActivityStatistics calledActivity = statistics.get(0);
    assertEquals("callActivity", calledActivity.getId());
    assertEquals(5, calledActivity.getInstances());
    query = historyService.createHistoricActivityStatisticsQuery(calledProcessId).orderByActivityId().asc();
    statistics = query.list();
    assertEquals(2, query.count());
    assertEquals(2, statistics.size());
    // task1
    HistoricActivityStatistics task1 = statistics.get(0);
    assertEquals("task1", task1.getId());
    assertEquals(15, task1.getInstances());
    // task2
    HistoricActivityStatistics task2 = statistics.get(1);
    assertEquals("task2", task2.getId());
    assertEquals(15, task2.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 10 with HistoricActivityStatistics

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

the class HistoricActivityStatisticsQueryTest method testQueryByFinished.

@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityStatisticsQueryTest.testSingleTask.bpmn20.xml")
public void testQueryByFinished() {
    String processDefinitionId = getProcessDefinitionId();
    startProcesses(5);
    HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().orderByActivityId().asc();
    List<HistoricActivityStatistics> statistics = query.list();
    assertEquals(2, query.count());
    assertEquals(2, statistics.size());
    // start
    HistoricActivityStatistics start = statistics.get(0);
    assertEquals("start", start.getId());
    assertEquals(0, start.getInstances());
    assertEquals(5, start.getFinished());
    // task
    HistoricActivityStatistics task = statistics.get(1);
    assertEquals("task", task.getId());
    assertEquals(5, task.getInstances());
    assertEquals(0, task.getFinished());
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) 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