use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryForMultipleVersionsWithFailedJobsAndIncidents.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryForMultipleVersionsWithFailedJobsAndIncidents() {
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();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
for (ProcessDefinition definition : definitions) {
runtimeService.startProcessInstanceById(definition.getId(), parameters);
}
executeAvailableJobs();
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidents().list();
Assert.assertEquals(2, statistics.size());
ProcessDefinitionStatistics definitionResult = statistics.get(0);
Assert.assertEquals(1, definitionResult.getInstances());
Assert.assertEquals(1, definitionResult.getFailedJobs());
List<IncidentStatistics> incidentStatistics = definitionResult.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());
definitionResult = statistics.get(1);
Assert.assertEquals(1, definitionResult.getInstances());
Assert.assertEquals(1, definitionResult.getFailedJobs());
incidentStatistics = definitionResult.getIncidentStatistics();
assertFalse(incidentStatistics.isEmpty());
assertEquals(1, incidentStatistics.size());
incident = incidentStatistics.get(0);
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType());
assertEquals(1, incident.getIncidentCount());
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceImpl method getStatistics.
@Override
public List<StatisticsResultDto> getStatistics(Boolean includeFailedJobs, Boolean includeRootIncidents, Boolean includeIncidents, String includeIncidentsForType) {
if (includeIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
}
if (includeIncidents != null && includeRootIncidents != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeRootIncidents can be set.");
}
if (includeRootIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set.");
}
ManagementService mgmtService = getProcessEngine().getManagementService();
ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();
if (includeFailedJobs != null && includeFailedJobs) {
query.includeFailedJobs();
}
if (includeIncidents != null && includeIncidents) {
query.includeIncidents();
} else if (includeIncidentsForType != null) {
query.includeIncidentsForType(includeIncidentsForType);
} else if (includeRootIncidents != null && includeRootIncidents) {
query.includeRootIncidents();
}
List<ProcessDefinitionStatistics> queryResults = query.list();
List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
for (ProcessDefinitionStatistics queryResult : queryResults) {
StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
results.add(dto);
}
return results;
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithFailedJobs.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithFailedJobs() {
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().includeFailedJobs().list();
Assert.assertEquals(1, statistics.size());
ProcessDefinitionStatistics definitionResult = statistics.get(0);
Assert.assertEquals(2, definitionResult.getInstances());
Assert.assertEquals(1, definitionResult.getFailedJobs());
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsQueryTest method testSubprocessProcessDefinitionStatisticsQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testSubprocessStatisticsQuery.bpmn20.xml")
public void testSubprocessProcessDefinitionStatisticsQuery() {
runtimeService.startProcessInstanceByKey("ExampleProcess");
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 testProcessDefinitionStatisticsQueryForMultipleVersions.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryForMultipleVersions() {
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().includeIncidents().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);
}
Aggregations