use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createHistoricActivityStatisticsMock.
private void createHistoricActivityStatisticsMock() {
List<HistoricActivityStatistics> statistics = MockProvider.createMockHistoricActivityStatistics();
HistoricActivityStatisticsQuery query = mock(HistoricActivityStatisticsQuery.class);
when(mockHistoryService.createHistoricActivityStatisticsQuery(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(query);
when(query.list()).thenReturn(statistics);
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingCompleteScopeWithReadHistoryPermissionOnAnyProcessDefinition.
public void testQueryIncludingCompleteScopeWithReadHistoryPermissionOnAnyProcessDefinition() {
// 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, ANY, userId, READ_HISTORY);
// when
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCompleteScope();
// then
verifyQueryResults(query, 2);
List<HistoricActivityStatistics> statistics = query.list();
HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
verifyStatisticsResult(task, 2, 0, 0, 0);
HistoricActivityStatistics end = getStatisticsByKey(statistics, "theEnd");
verifyStatisticsResult(end, 0, 0, 0, 1);
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingAllWithoutAuthorization.
// historic activity statistics query (including all) //////////////////////////////////
public void testQueryIncludingAllWithoutAuthorization() {
// 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();
// when
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeFinished().includeCanceled().includeCompleteScope();
// then
verifyQueryResults(query, 0);
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingCanceledWithReadHistoryPermissionOnProcessDefinition.
public void testQueryIncludingCanceledWithReadHistoryPermissionOnProcessDefinition() {
// 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();
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
// when
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled();
// then
verifyQueryResults(query, 1);
List<HistoricActivityStatistics> statistics = query.list();
HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
verifyStatisticsResult(task, 2, 0, 1, 0);
}
use of org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityStatisticsAuthorizationTest method testQueryIncludingCanceledWithReadHistoryPermissionOnAnyProcessDefinition.
public void testQueryIncludingCanceledWithReadHistoryPermissionOnAnyProcessDefinition() {
// 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();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
// when
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId).includeCanceled();
// then
verifyQueryResults(query, 1);
List<HistoricActivityStatistics> statistics = query.list();
HistoricActivityStatistics task = getStatisticsByKey(statistics, "theTask");
verifyStatisticsResult(task, 2, 0, 1, 0);
}
Aggregations