Search in sources :

Example 11 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testQueryByIncidentsWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentsWithFailedTimerStartEvent() {
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult();
    executeAvailableJobs();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeIncidents().list();
    assertEquals(1, statistics.size());
    ActivityStatistics result = statistics.get(0);
    assertEquals("theStart", result.getId());
    // there is no running activity 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 : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithoutFailedJobs.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithoutFailedJobs() {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("fail", true);
    runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
    executeAvailableJobs();
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").singleResult();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics activityResult = statistics.get(0);
    Assert.assertEquals(1, activityResult.getInstances());
    Assert.assertEquals("theServiceTask", activityResult.getId());
    Assert.assertEquals(0, activityResult.getFailedJobs());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) HashMap(java.util.HashMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testCallActivityActivityStatisticsQuery.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml" })
public void testCallActivityActivityStatisticsQuery() {
    runtimeService.startProcessInstanceByKey("callExampleSubProcess");
    executeAvailableJobs();
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").singleResult();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().includeIncidents().list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics result = statistics.get(0);
    Assert.assertEquals(1, result.getInstances());
    Assert.assertEquals(0, result.getFailedJobs());
    assertTrue(result.getIncidentStatistics().isEmpty());
    ProcessDefinition callSubProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("callExampleSubProcess").singleResult();
    List<ActivityStatistics> callSubProcessStatistics = managementService.createActivityStatisticsQuery(callSubProcessDefinition.getId()).includeFailedJobs().includeIncidents().list();
    Assert.assertEquals(1, callSubProcessStatistics.size());
    result = callSubProcessStatistics.get(0);
    Assert.assertEquals(1, result.getInstances());
    Assert.assertEquals(0, result.getFailedJobs());
    assertTrue(result.getIncidentStatistics().isEmpty());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testAsyncInterruptingEventSubProcessActivityStatisticsQuery.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testAsyncInterruptingEventSubProcessStatisticsQuery.bpmn20.xml")
public void testAsyncInterruptingEventSubProcessActivityStatisticsQuery() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    runtimeService.correlateMessage("Message");
    // when
    ActivityStatistics activityStatistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).singleResult();
    // then
    assertNotNull(activityStatistics);
    assertEquals("eventSubprocess", activityStatistics.getId());
    assertEquals(1, activityStatistics.getInstances());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIncidentType.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithIncidentType() {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("fail", true);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);
    executeAvailableJobs();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).includeIncidentsForType("failedJob").list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics activityResult = statistics.get(0);
    List<IncidentStatistics> incidentStatistics = activityResult.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 : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)44 Deployment (org.camunda.bpm.engine.test.Deployment)25 Test (org.junit.Test)15 IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)14 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)2 Job (org.camunda.bpm.engine.runtime.Job)2 ManagementService (org.camunda.bpm.engine.ManagementService)1 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)1 HistoricCaseActivityStatistics (org.camunda.bpm.engine.history.HistoricCaseActivityStatistics)1 ActivityStatisticsQuery (org.camunda.bpm.engine.management.ActivityStatisticsQuery)1 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)1 ActivityStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)1