Search in sources :

Example 1 with IncidentStatistics

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

the class ActivityStatisticsResultDto method fromActivityStatistics.

public static ActivityStatisticsResultDto fromActivityStatistics(ActivityStatistics statistics) {
    ActivityStatisticsResultDto dto = new ActivityStatisticsResultDto();
    dto.id = statistics.getId();
    dto.instances = statistics.getInstances();
    dto.failedJobs = statistics.getFailedJobs();
    dto.incidents = new ArrayList<IncidentStatisticsResultDto>();
    for (IncidentStatistics incident : statistics.getIncidentStatistics()) {
        IncidentStatisticsResultDto incidentDto = IncidentStatisticsResultDto.fromIncidentStatistics(incident);
        dto.incidents.add(incidentDto);
    }
    return dto;
}
Also used : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 2 with IncidentStatistics

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

the class MockProvider method createMockActivityStatistics.

public static List<ActivityStatistics> createMockActivityStatistics() {
    ActivityStatistics statistics = mock(ActivityStatistics.class);
    when(statistics.getFailedJobs()).thenReturn(EXAMPLE_FAILED_JOBS);
    when(statistics.getInstances()).thenReturn(EXAMPLE_INSTANCES);
    when(statistics.getId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    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);
    ActivityStatistics anotherStatistics = mock(ActivityStatistics.class);
    when(anotherStatistics.getFailedJobs()).thenReturn(ANOTHER_EXAMPLE_FAILED_JOBS);
    when(anotherStatistics.getInstances()).thenReturn(ANOTHER_EXAMPLE_INSTANCES);
    when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    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<ActivityStatistics> activityResults = new ArrayList<ActivityStatistics>();
    activityResults.add(statistics);
    activityResults.add(anotherStatistics);
    return activityResults;
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) HistoricCaseActivityStatistics(org.camunda.bpm.engine.history.HistoricCaseActivityStatistics) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) ArrayList(java.util.ArrayList)

Example 3 with IncidentStatistics

use of org.camunda.bpm.engine.management.IncidentStatistics 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 4 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsWithReadInstancePermissionOnProcessDefinition.

public void testQueryIncludingIncidentsWithReadInstancePermissionOnProcessDefinition() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ, READ_INSTANCE);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(3, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(3, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 5 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsWithReadPermissionOnAnyProcessInstance.

public void testQueryIncludingIncidentsWithReadPermissionOnAnyProcessInstance() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(3, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(3, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Aggregations

IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)35 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)16 ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)14 HashMap (java.util.HashMap)11 ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)10 DeploymentStatistics (org.camunda.bpm.engine.management.DeploymentStatistics)9 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ArrayList (java.util.ArrayList)2 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)1 HistoricCaseActivityStatistics (org.camunda.bpm.engine.history.HistoricCaseActivityStatistics)1