Search in sources :

Example 16 with DeploymentStatistics

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

use of org.camunda.bpm.engine.management.DeploymentStatistics 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)

Example 18 with DeploymentStatistics

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

the class DeploymentStatisticsQueryTest method testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent() {
    executeAvailableJobs();
    List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().includeIncidents().list();
    assertEquals(1, statistics.size());
    DeploymentStatistics 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 : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) DeploymentStatistics(org.camunda.bpm.engine.management.DeploymentStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 19 with DeploymentStatistics

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

the class DeploymentStatisticsQueryTest method testDeploymentStatisticsQuery.

@Test
public void testDeploymentStatisticsQuery() {
    String deploymentName = "my deployment";
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml").addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml").name(deploymentName).deploy();
    runtimeService.startProcessInstanceByKey("MIExampleProcess");
    runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess");
    List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().list();
    Assert.assertEquals(1, statistics.size());
    DeploymentStatistics result = statistics.get(0);
    Assert.assertEquals(2, result.getInstances());
    Assert.assertEquals(0, result.getFailedJobs());
    Assert.assertEquals(deployment.getId(), result.getId());
    Assert.assertEquals(deploymentName, result.getName());
    // only compare time on second level (i.e. drop milliseconds)
    Calendar cal1 = Calendar.getInstance();
    cal1.setTime(deployment.getDeploymentTime());
    cal1.set(Calendar.MILLISECOND, 0);
    Calendar cal2 = Calendar.getInstance();
    cal2.setTime(result.getDeploymentTime());
    cal2.set(Calendar.MILLISECOND, 0);
    Assert.assertTrue(cal1.equals(cal2));
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : DeploymentStatistics(org.camunda.bpm.engine.management.DeploymentStatistics) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 20 with DeploymentStatistics

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

the class DeploymentStatisticsQueryTest method testQueryByIncidentTypeWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentTypeWithFailedTimerStartEvent() {
    executeAvailableJobs();
    List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeIncidentsForType(Incident.FAILED_JOB_HANDLER_TYPE).list();
    assertEquals(1, statistics.size());
    DeploymentStatistics 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 : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) DeploymentStatistics(org.camunda.bpm.engine.management.DeploymentStatistics) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

DeploymentStatistics (org.camunda.bpm.engine.management.DeploymentStatistics)31 DeploymentStatisticsQuery (org.camunda.bpm.engine.management.DeploymentStatisticsQuery)18 Deployment (org.camunda.bpm.engine.test.Deployment)11 IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)9 Test (org.junit.Test)9 HashMap (java.util.HashMap)5 Calendar (java.util.Calendar)1