Search in sources :

Example 21 with ProcessDefinitionStatistics

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());
}
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 22 with ProcessDefinitionStatistics

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

Example 23 with ProcessDefinitionStatistics

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);
}
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)

Example 24 with ProcessDefinitionStatistics

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

Example 25 with ProcessDefinitionStatistics

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