Search in sources :

Example 16 with ProcessDefinitionStatistics

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);
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) HashMap(java.util.HashMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with ProcessDefinitionStatistics

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;
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) ManagementService(org.camunda.bpm.engine.ManagementService) ArrayList(java.util.ArrayList) StatisticsResultDto(org.camunda.bpm.engine.rest.dto.StatisticsResultDto) ProcessDefinitionStatisticsResultDto(org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 18 with ProcessDefinitionStatistics

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());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 19 with ProcessDefinitionStatistics

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());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with ProcessDefinitionStatistics

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);
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)29 Deployment (org.camunda.bpm.engine.test.Deployment)19 Test (org.junit.Test)16 IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 HashMap (java.util.HashMap)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ProcessDefinitionStatisticsQuery (org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)3 ArrayList (java.util.ArrayList)2 ManagementService (org.camunda.bpm.engine.ManagementService)1 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)1 ProcessDefinitionStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1