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