Search in sources :

Example 6 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsQueryTest method testCallActivityProcessDefinitionStatisticsQuery.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityWithIncidentsWithoutFailedJobs.bpmn20.xml")
public void testCallActivityProcessDefinitionStatisticsQuery() {
    runtimeService.startProcessInstanceByKey("callExampleSubProcess");
    executeAvailableJobs();
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().list();
    Assert.assertEquals(2, statistics.size());
    for (ProcessDefinitionStatistics result : statistics) {
        if (result.getKey().equals("ExampleProcess")) {
            Assert.assertEquals(1, result.getInstances());
            Assert.assertEquals(1, result.getFailedJobs());
        } else if (result.getKey().equals("callExampleSubProcess")) {
            Assert.assertEquals(1, result.getInstances());
            Assert.assertEquals(0, result.getFailedJobs());
        } else {
            fail(result + " was not expected.");
        }
    }
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithoutRunningInstances.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithoutRunningInstances() {
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidents().list();
    Assert.assertEquals(1, statistics.size());
    ProcessDefinitionStatistics definitionResult = statistics.get(0);
    Assert.assertEquals(0, definitionResult.getInstances());
    Assert.assertEquals(0, definitionResult.getFailedJobs());
    statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().list();
    assertTrue(definitionResult.getIncidentStatistics().isEmpty());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsQueryTest method testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent() {
    executeAvailableJobs();
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidents().list();
    assertEquals(1, statistics.size());
    ProcessDefinitionStatistics result = statistics.get(0);
    // there is no running instance
    assertEquals(0, result.getInstances());
    // but there is one failed timer job
    assertEquals(1, result.getFailedJobs());
    List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics();
    // and 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());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsProperties.

public void testProcessDefinitionStatisticsProperties() {
    String resourceName = "org/camunda/bpm/engine/test/api/mgmt/ProcessDefinitionStatisticsQueryTest.testProcessDefinitionStatisticsProperties.bpmn20.xml";
    String deploymentId = deploymentForTenant("tenant1", resourceName);
    ProcessDefinitionStatistics processDefinitionStatistics = managementService.createProcessDefinitionStatisticsQuery().singleResult();
    assertEquals("testProcess", processDefinitionStatistics.getKey());
    assertEquals("process name", processDefinitionStatistics.getName());
    assertEquals("Examples", processDefinitionStatistics.getCategory());
    // it is not parsed for the statistics query
    assertEquals(null, processDefinitionStatistics.getDescription());
    assertEquals("tenant1", processDefinitionStatistics.getTenantId());
    assertEquals("v0.1.0", processDefinitionStatistics.getVersionTag());
    assertEquals(deploymentId, processDefinitionStatistics.getDeploymentId());
    assertEquals(resourceName, processDefinitionStatistics.getResourceName());
    assertEquals(null, processDefinitionStatistics.getDiagramResourceName());
    assertEquals(1, processDefinitionStatistics.getVersion());
    assertEquals(0, processDefinitionStatistics.getInstances());
    assertEquals(0, processDefinitionStatistics.getFailedJobs());
    assertTrue(processDefinitionStatistics.getIncidentStatistics().isEmpty());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 10 with ProcessDefinitionStatistics

use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithIncidentType.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithIncidentType() {
    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("failedJob").list();
    Assert.assertEquals(1, statistics.size());
    ProcessDefinitionStatistics definitionResult = statistics.get(0);
    Assert.assertEquals(2, definitionResult.getInstances());
    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)

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