Search in sources :

Example 36 with ActivityStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingInstancesWithMany.

public void testQueryIncludingInstancesWithMany() {
    // 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_DEFINITION, ANY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(1, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertTrue(statistics.getIncidentStatistics().isEmpty());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics)

Example 37 with ActivityStatistics

use of org.camunda.bpm.engine.management.ActivityStatistics 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 38 with ActivityStatistics

use of org.camunda.bpm.engine.management.ActivityStatistics 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 39 with ActivityStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingIncidentsWithoutAuthorizationOnProcessInstance.

// including incidents //////////////////////////////////////////////////////////////
public void testQueryIncludingIncidentsWithoutAuthorizationOnProcessInstance() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ);
    // when
    ActivityStatistics statistics = managementService.createActivityStatisticsQuery(processDefinitionId).includeIncidents().singleResult();
    // then
    assertNull(statistics);
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics)

Example 40 with ActivityStatistics

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

the class ActivityStatisticsAuthorizationTest method testQueryIncludingFailedJobsWithReadPermissionOnOneProcessInstance.

public void testQueryIncludingFailedJobsWithReadPermissionOnOneProcessInstance() {
    // 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).includeFailedJobs().singleResult();
    // then
    assertNotNull(statistics);
    assertEquals("scriptTask", statistics.getId());
    assertEquals(1, statistics.getInstances());
    assertEquals(1, statistics.getFailedJobs());
    assertTrue(statistics.getIncidentStatistics().isEmpty());
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics)

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