use of org.camunda.bpm.engine.management.IncidentStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIncidents.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithIncidents() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
executeAvailableJobs();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).includeIncidents().list();
Assert.assertEquals(1, statistics.size());
ActivityStatistics activityResult = statistics.get(0);
List<IncidentStatistics> incidentStatistics = activityResult.getIncidentStatistics();
assertFalse(incidentStatistics.isEmpty());
assertEquals(1, incidentStatistics.size());
IncidentStatistics incident = incidentStatistics.get(0);
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType());
assertEquals(1, incident.getIncidentCount());
}
use of org.camunda.bpm.engine.management.IncidentStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithIncidentsAndFailedJobs.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithIncidentsAndFailedJobs() {
runtimeService.startProcessInstanceByKey("ExampleProcess");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
executeAvailableJobs();
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().includeFailedJobs().list();
Assert.assertEquals(1, statistics.size());
ProcessDefinitionStatistics definitionResult = statistics.get(0);
Assert.assertEquals(2, definitionResult.getInstances());
Assert.assertEquals(1, definitionResult.getFailedJobs());
assertFalse(definitionResult.getIncidentStatistics().isEmpty());
assertEquals(1, definitionResult.getIncidentStatistics().size());
IncidentStatistics incidentStatistics = definitionResult.getIncidentStatistics().get(0);
Assert.assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistics.getIncidentType());
Assert.assertEquals(1, incidentStatistics.getIncidentCount());
}
use of org.camunda.bpm.engine.management.IncidentStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithIncidentsWithoutFailedJobs.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityWithIncidentsWithoutFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithIncidentsWithoutFailedJobs() {
runtimeService.startProcessInstanceByKey("callExampleSubProcess");
executeAvailableJobs();
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().includeFailedJobs().list();
Assert.assertEquals(2, statistics.size());
ProcessDefinitionStatistics callExampleSubProcessStaticstics = null;
ProcessDefinitionStatistics exampleSubProcessStaticstics = null;
for (ProcessDefinitionStatistics current : statistics) {
if (current.getKey().equals("callExampleSubProcess")) {
callExampleSubProcessStaticstics = current;
} else if (current.getKey().equals("ExampleProcess")) {
exampleSubProcessStaticstics = current;
} else {
fail(current.getKey() + " was not expected.");
}
}
assertNotNull(callExampleSubProcessStaticstics);
assertNotNull(exampleSubProcessStaticstics);
// "super" process definition
assertEquals(1, callExampleSubProcessStaticstics.getInstances());
assertEquals(0, callExampleSubProcessStaticstics.getFailedJobs());
assertFalse(callExampleSubProcessStaticstics.getIncidentStatistics().isEmpty());
assertEquals(1, callExampleSubProcessStaticstics.getIncidentStatistics().size());
IncidentStatistics incidentStatistics = callExampleSubProcessStaticstics.getIncidentStatistics().get(0);
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistics.getIncidentType());
assertEquals(1, incidentStatistics.getIncidentCount());
// "called" process definition
assertEquals(1, exampleSubProcessStaticstics.getInstances());
assertEquals(1, exampleSubProcessStaticstics.getFailedJobs());
assertFalse(exampleSubProcessStaticstics.getIncidentStatistics().isEmpty());
assertEquals(1, exampleSubProcessStaticstics.getIncidentStatistics().size());
incidentStatistics = exampleSubProcessStaticstics.getIncidentStatistics().get(0);
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistics.getIncidentType());
assertEquals(1, incidentStatistics.getIncidentCount());
}
use of org.camunda.bpm.engine.management.IncidentStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testQueryByIncidentsWithFailedTimerStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentsWithFailedTimerStartEvent() {
executeAvailableJobs();
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().list();
assertEquals(1, statistics.size());
ProcessDefinitionStatistics result = statistics.get(0);
// there is no running instance
assertEquals(0, result.getInstances());
List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics();
// but there is one incident for the failed timer job
assertEquals(1, incidentStatistics.size());
IncidentStatistics incidentStatistic = incidentStatistics.get(0);
assertEquals(1, incidentStatistic.getIncidentCount());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistic.getIncidentType());
}
use of org.camunda.bpm.engine.management.IncidentStatistics in project camunda-bpm-platform by camunda.
the class MultiTenancySharedProcessDefinitionStatisticsQueryTest method instancesFailedJobsAndIncidentsCountWithAuthenticatedTenant.
@Test
public void instancesFailedJobsAndIncidentsCountWithAuthenticatedTenant() {
testRule.deploy(failingProcess);
startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY);
testRule.executeAvailableJobs();
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
List<ProcessDefinitionStatistics> processDefinitionsStatistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidents().list();
// then
assertEquals(1, processDefinitionsStatistics.size());
ProcessDefinitionStatistics processDefinitionStatistics = processDefinitionsStatistics.get(0);
assertEquals(2, processDefinitionStatistics.getInstances());
assertEquals(2, processDefinitionStatistics.getFailedJobs());
List<IncidentStatistics> incidentStatistics = processDefinitionStatistics.getIncidentStatistics();
assertEquals(1, incidentStatistics.size());
assertEquals(2, incidentStatistics.get(0).getIncidentCount());
}
Aggregations