use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyStatisticsQueryTest method testQueryNoAuthenticatedTenantsForProcessDefinitionStatistics.
public void testQueryNoAuthenticatedTenantsForProcessDefinitionStatistics() {
identityService.setAuthentication("user", null, null);
ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
assertThat(query.count(), is(1L));
Set<String> tenantIds = collectDefinitionTenantIds(query.list());
assertThat(tenantIds.size(), is(1));
assertThat(tenantIds.iterator().next(), is(nullValue()));
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyStatisticsQueryTest method testQueryAuthenticatedTenantsForProcessDefinitionStatistics.
public void testQueryAuthenticatedTenantsForProcessDefinitionStatistics() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));
ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
assertThat(query.count(), is(3L));
Set<String> tenantIds = collectDefinitionTenantIds(query.list());
assertThat(tenantIds.size(), is(3));
assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO));
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsAuthorizationTest method testQueryWithMultiple.
public void testQueryWithMultiple() {
// given
createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
// when
ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
// then
verifyQueryResults(query, 2);
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsAuthorizationTest method testQueryWithReadPermissionOnOneTaskProcess.
public void testQueryWithReadPermissionOnOneTaskProcess() {
// given
createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
// when
ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
// then
verifyQueryResults(query, 1);
ProcessDefinitionStatistics statistics = query.singleResult();
assertEquals(ONE_TASK_PROCESS_KEY, statistics.getKey());
assertEquals(0, statistics.getInstances());
assertEquals(0, statistics.getFailedJobs());
assertTrue(statistics.getIncidentStatistics().isEmpty());
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceImpl method getStatistics.
@Override
public List<StatisticsResultDto> getStatistics(Boolean includeFailedJobs, Boolean includeRootIncidents, Boolean includeIncidents, String includeIncidentsForType) {
if (includeIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
}
if (includeIncidents != null && includeRootIncidents != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeRootIncidents can be set.");
}
if (includeRootIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set.");
}
ManagementService mgmtService = getProcessEngine().getManagementService();
ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();
if (includeFailedJobs != null && includeFailedJobs) {
query.includeFailedJobs();
}
if (includeIncidents != null && includeIncidents) {
query.includeIncidents();
} else if (includeIncidentsForType != null) {
query.includeIncidentsForType(includeIncidentsForType);
} else if (includeRootIncidents != null && includeRootIncidents) {
query.includeRootIncidents();
}
List<ProcessDefinitionStatistics> queryResults = query.list();
List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
for (ProcessDefinitionStatistics queryResult : queryResults) {
StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
results.add(dto);
}
return results;
}
Aggregations