Search in sources :

Example 1 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class MockProvider method createMockProcessDefinitionStatistics.

// statistics
public static List<ProcessDefinitionStatistics> createMockProcessDefinitionStatistics() {
    ProcessDefinitionStatistics statistics = mock(ProcessDefinitionStatistics.class);
    when(statistics.getFailedJobs()).thenReturn(EXAMPLE_FAILED_JOBS);
    when(statistics.getInstances()).thenReturn(EXAMPLE_INSTANCES);
    when(statistics.getId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
    when(statistics.getName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME);
    when(statistics.getKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
    when(statistics.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
    when(statistics.getVersionTag()).thenReturn(EXAMPLE_VERSION_TAG);
    when(statistics.getCategory()).thenReturn(EXAMPLE_PROCESS_DEFINITION_CATEGORY);
    when(statistics.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
    when(statistics.getDiagramResourceName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_DIAGRAM_RESOURCE_NAME);
    when(statistics.getResourceName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_RESOURCE_NAME);
    when(statistics.getVersion()).thenReturn(EXAMPLE_PROCESS_DEFINITION_VERSION);
    when(statistics.getDescription()).thenReturn(EXAMPLE_PROCESS_DEFINITION_DESCRIPTION);
    IncidentStatistics incidentStaticits = mock(IncidentStatistics.class);
    when(incidentStaticits.getIncidentType()).thenReturn(EXAMPLE_INCIDENT_TYPE);
    when(incidentStaticits.getIncidentCount()).thenReturn(EXAMPLE_INCIDENT_COUNT);
    List<IncidentStatistics> exampleIncidentList = new ArrayList<IncidentStatistics>();
    exampleIncidentList.add(incidentStaticits);
    when(statistics.getIncidentStatistics()).thenReturn(exampleIncidentList);
    ProcessDefinitionStatistics anotherStatistics = mock(ProcessDefinitionStatistics.class);
    when(anotherStatistics.getFailedJobs()).thenReturn(ANOTHER_EXAMPLE_FAILED_JOBS);
    when(anotherStatistics.getInstances()).thenReturn(ANOTHER_EXAMPLE_INSTANCES);
    when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID);
    when(anotherStatistics.getName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME);
    when(anotherStatistics.getKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
    when(anotherStatistics.getTenantId()).thenReturn(ANOTHER_EXAMPLE_TENANT_ID);
    when(anotherStatistics.getVersionTag()).thenReturn(ANOTHER_EXAMPLE_VERSION_TAG);
    IncidentStatistics anotherIncidentStaticits = mock(IncidentStatistics.class);
    when(anotherIncidentStaticits.getIncidentType()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_TYPE);
    when(anotherIncidentStaticits.getIncidentCount()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_COUNT);
    List<IncidentStatistics> anotherExampleIncidentList = new ArrayList<IncidentStatistics>();
    anotherExampleIncidentList.add(anotherIncidentStaticits);
    when(anotherStatistics.getIncidentStatistics()).thenReturn(anotherExampleIncidentList);
    List<ProcessDefinitionStatistics> processDefinitionResults = new ArrayList<ProcessDefinitionStatistics>();
    processDefinitionResults.add(statistics);
    processDefinitionResults.add(anotherStatistics);
    return processDefinitionResults;
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) ArrayList(java.util.ArrayList)

Example 2 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingIncidentsAndFailedJobsWithoutProcessInstanceAuthorizations.

// including incidents and failed jobs ///////////////////////////////////////////////////////////////
public void testQueryIncludingIncidentsAndFailedJobsWithoutProcessInstanceAuthorizations() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
    // when
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().includeFailedJobs().list();
    // then
    assertEquals(2, statistics.size());
    ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
    verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
    ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
    verifyStatisticsResult(oneIncidentProcessStatistics, 3, 3, 3);
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics)

Example 3 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryWithReadPermissionOnOneTaskProcess.

public void testQueryWithReadPermissionOnOneTaskProcess() {
    // given
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
    // when
    ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessDefinitionStatistics statistics = query.singleResult();
    assertEquals(ONE_TASK_PROCESS_KEY, statistics.getKey());
    assertEquals(0, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertTrue(statistics.getIncidentStatistics().isEmpty());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 4 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingFailedJobsWithoutProcessInstanceAuthorizations.

// including failed jobs ////////////////////////////////////////////////////////////
public void testQueryIncludingFailedJobsWithoutProcessInstanceAuthorizations() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
    // when
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().list();
    // then
    assertEquals(2, statistics.size());
    ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
    verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
    ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
    verifyStatisticsResult(oneIncidentProcessStatistics, 3, 3, 0);
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics)

Example 5 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingInstancesWithoutProcessInstanceAuthorizations.

// including instances //////////////////////////////////////////////////////////////
public void testQueryIncludingInstancesWithoutProcessInstanceAuthorizations() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
    // when
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().list();
    // then
    assertEquals(2, statistics.size());
    ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
    verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
    ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
    verifyStatisticsResult(oneIncidentProcessStatistics, 3, 0, 0);
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics)

Aggregations

ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)29 Deployment (org.camunda.bpm.engine.test.Deployment)19 Test (org.junit.Test)16 IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 HashMap (java.util.HashMap)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ProcessDefinitionStatisticsQuery (org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)3 ArrayList (java.util.ArrayList)2 ManagementService (org.camunda.bpm.engine.ManagementService)1 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)1 ProcessDefinitionStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1