Search in sources :

Example 21 with ActivityStatistics

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

the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodyParallelTasksActivityStatistics.

@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testStartBeforeInnerActivityWithMiBodyParallelTasksActivityStatistics() {
    // given the mi body is not yet instantiated
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    // when
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("miTasks").execute();
    // then the activity instance statistics are correct
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).list();
    assertEquals(2, statistics.size());
    ActivityStatistics miTasksStatistics = getStatisticsForActivity(statistics, "miTasks");
    assertNotNull(miTasksStatistics);
    assertEquals(1, miTasksStatistics.getInstances());
    ActivityStatistics beforeTaskStatistics = getStatisticsForActivity(statistics, "beforeTask");
    assertNotNull(beforeTaskStatistics);
    assertEquals(1, beforeTaskStatistics.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 22 with ActivityStatistics

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

the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySequentialSubprocessActivityStatistics.

@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySequentialSubprocessActivityStatistics() {
    // given the mi body is not yet instantiated
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
    // when
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("subProcessTask").execute();
    // then the activity instance statistics are correct
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).list();
    assertEquals(2, statistics.size());
    ActivityStatistics miTasksStatistics = getStatisticsForActivity(statistics, "subProcessTask");
    assertNotNull(miTasksStatistics);
    assertEquals(1, miTasksStatistics.getInstances());
    ActivityStatistics beforeTaskStatistics = getStatisticsForActivity(statistics, "beforeTask");
    assertNotNull(beforeTaskStatistics);
    assertEquals(1, beforeTaskStatistics.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 23 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIntermediateTimer.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testActivityStatisticsQueryWithIntermediateTimer.bpmn20.xml")
public void testActivityStatisticsQueryWithIntermediateTimer() {
    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("theTimer", 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 24 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testQueryByIncidentTypeWithFailedTimerStartEvent.

@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml")
public void testQueryByIncidentTypeWithFailedTimerStartEvent() {
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult();
    executeAvailableJobs();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(definition.getId()).includeIncidentsForType(Incident.FAILED_JOB_HANDLER_TYPE).list();
    assertEquals(1, statistics.size());
    ActivityStatistics 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 : 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 25 with ActivityStatistics

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

the class ActivityStatisticsQueryTest method testActivityStatisticsQueryWithIncidentsWithoutFailedJobs.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityWithIncidentsWithoutFailedJobs.bpmn20.xml")
public void testActivityStatisticsQueryWithIncidentsWithoutFailedJobs() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callExampleSubProcess");
    executeAvailableJobs();
    List<ActivityStatistics> statistics = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()).includeIncidents().includeFailedJobs().list();
    Assert.assertEquals(1, statistics.size());
    ActivityStatistics activityResult = statistics.get(0);
    Assert.assertEquals("callSubProcess", activityResult.getId());
    // has no failed jobs
    Assert.assertEquals(0, activityResult.getFailedJobs());
    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());
    // ... but has one incident
    assertEquals(1, incident.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics) 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