Search in sources :

Example 31 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsAndFailedJobsWithReadInstancePermissionOnProcessDefinition.

public void testQueryIncludingIncidentsAndFailedJobsWithReadInstancePermissionOnProcessDefinition() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ, READ_INSTANCE);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().includeFailedJobs().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(3, statistics.getInstances());
    assertEquals(3, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(3, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 32 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsAndFailedJobsWithReadPermissionOnAnyProcessInstance.

public void testQueryIncludingIncidentsAndFailedJobsWithReadPermissionOnAnyProcessInstance() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().includeFailedJobs().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(3, statistics.getInstances());
    assertEquals(3, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(3, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 33 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsWithReadPermissionOnOneProcessInstance.

public void testQueryIncludingIncidentsWithReadPermissionOnOneProcessInstance() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    disableAuthorization();
    String processInstanceId = runtimeService.createProcessInstanceQuery().list().get(0).getId();
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(1, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(1, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 34 with IncidentStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsAndFailedJobsWithReadPermissionOnOneProcessInstance.

public void testQueryIncludingIncidentsAndFailedJobsWithReadPermissionOnOneProcessInstance() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    disableAuthorization();
    String processInstanceId = runtimeService.createProcessInstanceQuery().list().get(0).getId();
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().includeFailedJobs().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(1, statistics.getInstances());
    assertEquals(1, statistics.getFailedJobs());
    assertFalse(statistics.getIncidentStatistics().isEmpty());
    IncidentStatistics incidentStatistics = statistics.getIncidentStatistics().get(0);
    assertEquals(1, incidentStatistics.getIncidentCount());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Example 35 with IncidentStatistics

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

the class ProcessDefinitionStatisticsResultDto method fromProcessDefinitionStatistics.

public static ProcessDefinitionStatisticsResultDto fromProcessDefinitionStatistics(ProcessDefinitionStatistics statistics) {
    ProcessDefinitionStatisticsResultDto dto = new ProcessDefinitionStatisticsResultDto();
    dto.definition = ProcessDefinitionDto.fromProcessDefinition(statistics);
    dto.id = statistics.getId();
    dto.instances = statistics.getInstances();
    dto.failedJobs = statistics.getFailedJobs();
    dto.incidents = new ArrayList<IncidentStatisticsResultDto>();
    for (IncidentStatistics incident : statistics.getIncidentStatistics()) {
        IncidentStatisticsResultDto incidentDto = IncidentStatisticsResultDto.fromIncidentStatistics(incident);
        dto.incidents.add(incidentDto);
    }
    return dto;
}
Also used : IncidentStatistics(org.camunda.bpm.engine.management.IncidentStatistics)

Aggregations

IncidentStatistics (org.camunda.bpm.engine.management.IncidentStatistics)35 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)16 ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)14 HashMap (java.util.HashMap)11 ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)10 DeploymentStatistics (org.camunda.bpm.engine.management.DeploymentStatistics)9 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ArrayList (java.util.ArrayList)2 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)1 HistoricCaseActivityStatistics (org.camunda.bpm.engine.history.HistoricCaseActivityStatistics)1