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