use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithInvalidIncidentType.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithInvalidIncidentType() {
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().includeIncidentsForType("invalid").list();
Assert.assertEquals(1, statistics.size());
ProcessDefinitionStatistics definitionResult = statistics.get(0);
Assert.assertEquals(2, definitionResult.getInstances());
assertTrue(definitionResult.getIncidentStatistics().isEmpty());
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testMultiInstanceProcessDefinitionStatisticsQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml")
public void testMultiInstanceProcessDefinitionStatisticsQuery() {
runtimeService.startProcessInstanceByKey("MIExampleProcess");
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().list();
Assert.assertEquals(1, statistics.size());
ProcessDefinitionStatistics result = statistics.get(0);
Assert.assertEquals(1, result.getInstances());
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryForMultipleVersionsWithIncidentType.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryForMultipleVersionsWithIncidentType() {
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml").deploy();
List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").list();
for (ProcessDefinition definition : definitions) {
runtimeService.startProcessInstanceById(definition.getId());
}
executeAvailableJobs();
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidentsForType("failedJob").list();
Assert.assertEquals(2, statistics.size());
ProcessDefinitionStatistics definitionResult = statistics.get(0);
Assert.assertEquals(1, definitionResult.getInstances());
Assert.assertEquals(0, definitionResult.getFailedJobs());
assertTrue(definitionResult.getIncidentStatistics().isEmpty());
definitionResult = statistics.get(1);
Assert.assertEquals(1, definitionResult.getInstances());
Assert.assertEquals(0, definitionResult.getFailedJobs());
assertTrue(definitionResult.getIncidentStatistics().isEmpty());
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics 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.ProcessDefinitionStatistics 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());
}
Aggregations