Search in sources :

Example 26 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testNonInterruptingBoundaryEventActivityStatisticsQuery.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testNonInterruptingBoundaryEventStatisticsQuery.bpmn20.xml")
public void testNonInterruptingBoundaryEventActivityStatisticsQuery() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    Job boundaryJob = managementService.createJobQuery().singleResult();
    managementService.executeJob(boundaryJob.getId());
    // when
    List<ActivityStatistics> activityStatistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).list();
    // then
    assertEquals(2, activityStatistics.size());
    ActivityStatistics userTaskStatistics = getStatistics(activityStatistics, "task");
    assertNotNull(userTaskStatistics);
    assertEquals("task", userTaskStatistics.getId());
    assertEquals(1, userTaskStatistics.getInstances());
    ActivityStatistics afterBoundaryStatistics = getStatistics(activityStatistics, "afterBoundaryTask");
    assertNotNull(afterBoundaryStatistics);
    assertEquals("afterBoundaryTask", afterBoundaryStatistics.getId());
    assertEquals(1, afterBoundaryStatistics.getInstances());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 27 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testQueryByFailedJobsWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByFailedJobsWithFailedTimerStartEvent() {
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult();
    executeAvailableJobs();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().list();
    assertEquals(1, statistics.size());
    ActivityStatistics result = statistics.get(0);
    // there is no running instance
    assertEquals(0, result.getInstances());
    // but there is one failed timer job
    assertEquals(1, result.getFailedJobs());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 28 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQuery.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQuery.bpmn20.xml")
public void testActivityStatisticsQuery() {
    runtimeService.startProcessInstanceByKey("ExampleProcess");
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").singleResult();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().includeIncidents().list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics activityResult = statistics.get(0);
    Assert.assertEquals(1, activityResult.getInstances());
    Assert.assertEquals("theTask", activityResult.getId());
    Assert.assertEquals(0, activityResult.getFailedJobs());
    assertTrue(activityResult.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 29 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithInvalidIncidentType.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithInvalidIncidentType() {
    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("invalid").list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics activityResult = statistics.get(0);
    List<IncidentStatistics> incidentStatistics = activityResult.getIncidentStatistics();
    assertTrue(incidentStatistics.isEmpty());
}
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)

Example 30 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIncidents.

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