Search in sources :

Example 1 with HistoricActivityStatistics

use of org.camunda.bpm.engine.history.HistoricActivityStatistics 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);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 2 with HistoricActivityStatistics

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

the class MockProvider method createMockHistoricActivityStatistics.

public static List<HistoricActivityStatistics> createMockHistoricActivityStatistics() {
    HistoricActivityStatistics statistics = mock(HistoricActivityStatistics.class);
    when(statistics.getId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(statistics.getInstances()).thenReturn(EXAMPLE_INSTANCES_LONG);
    when(statistics.getCanceled()).thenReturn(EXAMPLE_CANCELED_LONG);
    when(statistics.getFinished()).thenReturn(EXAMPLE_FINISHED_LONG);
    when(statistics.getCompleteScope()).thenReturn(EXAMPLE_COMPLETE_SCOPE_LONG);
    HistoricActivityStatistics anotherStatistics = mock(HistoricActivityStatistics.class);
    when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    when(anotherStatistics.getInstances()).thenReturn(ANOTHER_EXAMPLE_INSTANCES_LONG);
    when(anotherStatistics.getCanceled()).thenReturn(ANOTHER_EXAMPLE_CANCELED_LONG);
    when(anotherStatistics.getFinished()).thenReturn(ANOTHER_EXAMPLE_FINISHED_LONG);
    when(anotherStatistics.getCompleteScope()).thenReturn(ANOTHER_EXAMPLE_COMPLETE_SCOPE_LONG);
    List<HistoricActivityStatistics> activityResults = new ArrayList<HistoricActivityStatistics>();
    activityResults.add(statistics);
    activityResults.add(anotherStatistics);
    return activityResults;
}
Also used : ArrayList(java.util.ArrayList) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 3 with HistoricActivityStatistics

use of org.camunda.bpm.engine.history.HistoricActivityStatistics 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);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 4 with HistoricActivityStatistics

use of org.camunda.bpm.engine.history.HistoricActivityStatistics 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);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

Example 5 with HistoricActivityStatistics

use of org.camunda.bpm.engine.history.HistoricActivityStatistics 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);
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics)

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