Search in sources :

Example 16 with IncidentStatistics

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

the class ProcessDefinitionStatisticsQueryTest method testProcessDefinitionStatisticsQueryWithIncidents.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testProcessDefinitionStatisticsQueryWithIncidents() {
    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().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)

Example 17 with IncidentStatistics

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

the class ProcessDefinitionStatisticsQueryTest method testQueryByIncidentTypeWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentTypeWithFailedTimerStartEvent() {
    executeAvailableJobs();
    List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidentsForType(Incident.FAILED_JOB_HANDLER_TYPE).list();
    assertEquals(1, statistics.size());
    ProcessDefinitionStatistics result = statistics.get(0);
    // there is no running instance
    assertEquals(0, result.getInstances());
    List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics();
    // but 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 18 with IncidentStatistics

use of org.camunda.bpm.engine.management.IncidentStatistics 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 19 with IncidentStatistics

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

the class DeploymentStatisticsQueryTest method testDeploymentStatisticsQueryWithInvalidIncidentType.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml" })
public void testDeploymentStatisticsQueryWithInvalidIncidentType() {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("fail", true);
    runtimeService.startProcessInstanceByKey("MIExampleProcess");
    runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
    executeAvailableJobs();
    List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeIncidentsForType("invalid").list();
    assertFalse(statistics.isEmpty());
    assertEquals(1, statistics.size());
    DeploymentStatistics result = statistics.get(0);
    List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics();
    assertTrue(incidentStatistics.isEmpty());
}
Also used : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) DeploymentStatistics(org.camunda.bpm.engine.management.DeploymentStatistics) HashMap(java.util.HashMap) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with IncidentStatistics

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

the class DeploymentStatisticsQueryTest method testDeploymentStatisticsQueryWithIncidentsAndFailedJobs.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml" })
public void testDeploymentStatisticsQueryWithIncidentsAndFailedJobs() {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("fail", true);
    runtimeService.startProcessInstanceByKey("MIExampleProcess");
    runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
    executeAvailableJobs();
    List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeIncidents().includeFailedJobs().list();
    assertFalse(statistics.isEmpty());
    assertEquals(1, statistics.size());
    DeploymentStatistics result = statistics.get(0);
    Assert.assertEquals(1, result.getFailedJobs());
    List<IncidentStatistics> incidentStatistics = result.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());
}
Also used : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) DeploymentStatistics(org.camunda.bpm.engine.management.DeploymentStatistics) HashMap(java.util.HashMap) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)35 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)16 ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)14 HashMap (java.util.HashMap)11 ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)10 DeploymentStatistics (org.camunda.bpm.engine.management.DeploymentStatistics)9 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ArrayList (java.util.ArrayList)2 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)1 HistoricCaseActivityStatistics (org.camunda.bpm.engine.history.HistoricCaseActivityStatistics)1