Search in sources :

Example 16 with ActivityStatistics

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());
}
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 17 with ActivityStatistics

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());
}
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 18 with ActivityStatistics

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());
}
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 19 with ActivityStatistics

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());
    }
}
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 20 with ActivityStatistics

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();
}
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)

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