use of org.camunda.bpm.engine.management.ActivityStatistics 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());
}
use of org.camunda.bpm.engine.management.ActivityStatistics 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());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodyParallelSubprocessActivityStatistics.
@Deployment(resources = PARALLEL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodyParallelSubprocessActivityStatistics() {
// given the mi body is not yet instantiated
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelSubprocess");
// 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());
}
use of org.camunda.bpm.engine.management.ActivityStatistics in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySequentialTasksActivityStatistics.
@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_TASK_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySequentialTasksActivityStatistics() {
// given the mi body is not yet instantiated
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialUserTasks");
// 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());
}
Aggregations