use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testParallelMultiInstanceActivityStatisticsQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml")
public void testParallelMultiInstanceActivityStatisticsQuery() {
runtimeService.startProcessInstanceByKey("MIExampleProcess");
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("MIExampleProcess").singleResult();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().includeIncidents().list();
Assert.assertEquals(1, statistics.size());
ActivityStatistics activityResult = statistics.get(0);
Assert.assertEquals(3, activityResult.getInstances());
Assert.assertEquals("theTask", activityResult.getId());
Assert.assertEquals(0, activityResult.getFailedJobs());
assertTrue(activityResult.getIncidentStatistics().isEmpty());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testManyInstancesActivityStatisticsQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQuery.bpmn20.xml")
public void testManyInstancesActivityStatisticsQuery() {
runtimeService.startProcessInstanceByKey("ExampleProcess");
runtimeService.startProcessInstanceByKey("ExampleProcess");
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(3, activityResult.getInstances());
Assert.assertEquals("theTask", activityResult.getId());
Assert.assertEquals(0, activityResult.getFailedJobs());
assertTrue(activityResult.getIncidentStatistics().isEmpty());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByFailedJobsAndIncidentsWithFailedTimerStartEvent() {
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult();
executeAvailableJobs();
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeFailedJobs().includeIncidents().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());
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());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ActivityStatisticsQueryTest method testParallelGatewayActivityStatisticsQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml")
public void testParallelGatewayActivityStatisticsQuery() {
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ParGatewayExampleProcess").singleResult();
runtimeService.startProcessInstanceById(definition.getId());
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).list();
Assert.assertEquals(2, statistics.size());
for (ActivityStatistics result : statistics) {
Assert.assertEquals(1, result.getInstances());
}
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testStartBeforeAsyncAfterTaskActivityStatistics.
@Deployment(resources = ASYNC_AFTER_FAILING_TASK_PROCESS)
public void testStartBeforeAsyncAfterTaskActivityStatistics() {
// given a process instance with an async task in a subprocess
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingAfterAsyncTask");
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// there is one statistics instance
List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).includeFailedJobs().includeIncidents().list();
assertEquals(1, statistics.size());
assertEquals("task1", statistics.get(0).getId());
assertEquals(0, statistics.get(0).getFailedJobs());
assertEquals(0, statistics.get(0).getIncidentStatistics().size());
assertEquals(1, statistics.get(0).getInstances());
// when
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task1").execute();
// then there are statistics instances of task1
statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).includeFailedJobs().includeIncidents().list();
assertEquals(1, statistics.size());
assertEquals("task1", statistics.get(0).getId());
assertEquals(0, statistics.get(0).getFailedJobs());
assertEquals(0, statistics.get(0).getIncidentStatistics().size());
assertEquals(2, statistics.get(0).getInstances());
// when all jobs are executed
executeAvailableJobs();
}
Aggregations