use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testQueryByIncidentsWithFailedTimerStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentsWithFailedTimerStartEvent() {
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult();
executeAvailableJobs();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeIncidents().list();
assertEquals(1, statistics.size());
ActivityStatistics result = statistics.get(0);
assertEquals("theStart", result.getId());
// there is no running activity 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.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithoutFailedJobs.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithoutFailedJobs() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
executeAvailableJobs();
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").singleResult();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).list();
Assert.assertEquals(1, statistics.size());
ActivityStatistics activityResult = statistics.get(0);
Assert.assertEquals(1, activityResult.getInstances());
Assert.assertEquals("theServiceTask", activityResult.getId());
Assert.assertEquals(0, activityResult.getFailedJobs());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testCallActivityActivityStatisticsQuery.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml" })
public void testCallActivityActivityStatisticsQuery() {
runtimeService.startProcessInstanceByKey("callExampleSubProcess");
executeAvailableJobs();
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").singleResult();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().includeIncidents().list();
Assert.assertEquals(1, statistics.size());
ActivityStatistics result = statistics.get(0);
Assert.assertEquals(1, result.getInstances());
Assert.assertEquals(0, result.getFailedJobs());
assertTrue(result.getIncidentStatistics().isEmpty());
ProcessDefinition callSubProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("callExampleSubProcess").singleResult();
List<ActivityStatistics> callSubProcessStatistics = managementService.createActivityStatisticsQuery(callSubProcessDefinition.getId()).includeFailedJobs().includeIncidents().list();
Assert.assertEquals(1, callSubProcessStatistics.size());
result = callSubProcessStatistics.get(0);
Assert.assertEquals(1, result.getInstances());
Assert.assertEquals(0, result.getFailedJobs());
assertTrue(result.getIncidentStatistics().isEmpty());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testAsyncInterruptingEventSubProcessActivityStatisticsQuery.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testAsyncInterruptingEventSubProcessStatisticsQuery.bpmn20.xml")
public void testAsyncInterruptingEventSubProcessActivityStatisticsQuery() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
runtimeService.correlateMessage("Message");
// when
ActivityStatistics activityStatistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).singleResult();
// then
assertNotNull(activityStatistics);
assertEquals("eventSubprocess", activityStatistics.getId());
assertEquals(1, activityStatistics.getInstances());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIncidentType.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithIncidentType() {
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()).includeIncidentsForType("failedJob").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());
}
Aggregations