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