use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class MockProvider method createMockProcessDefinitionStatistics.
// statistics
public static List<ProcessDefinitionStatistics> createMockProcessDefinitionStatistics() {
ProcessDefinitionStatistics statistics = mock(ProcessDefinitionStatistics.class);
when(statistics.getFailedJobs()).thenReturn(EXAMPLE_FAILED_JOBS);
when(statistics.getInstances()).thenReturn(EXAMPLE_INSTANCES);
when(statistics.getId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
when(statistics.getName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME);
when(statistics.getKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
when(statistics.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
when(statistics.getVersionTag()).thenReturn(EXAMPLE_VERSION_TAG);
when(statistics.getCategory()).thenReturn(EXAMPLE_PROCESS_DEFINITION_CATEGORY);
when(statistics.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
when(statistics.getDiagramResourceName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_DIAGRAM_RESOURCE_NAME);
when(statistics.getResourceName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_RESOURCE_NAME);
when(statistics.getVersion()).thenReturn(EXAMPLE_PROCESS_DEFINITION_VERSION);
when(statistics.getDescription()).thenReturn(EXAMPLE_PROCESS_DEFINITION_DESCRIPTION);
IncidentStatistics incidentStaticits = mock(IncidentStatistics.class);
when(incidentStaticits.getIncidentType()).thenReturn(EXAMPLE_INCIDENT_TYPE);
when(incidentStaticits.getIncidentCount()).thenReturn(EXAMPLE_INCIDENT_COUNT);
List<IncidentStatistics> exampleIncidentList = new ArrayList<IncidentStatistics>();
exampleIncidentList.add(incidentStaticits);
when(statistics.getIncidentStatistics()).thenReturn(exampleIncidentList);
ProcessDefinitionStatistics anotherStatistics = mock(ProcessDefinitionStatistics.class);
when(anotherStatistics.getFailedJobs()).thenReturn(ANOTHER_EXAMPLE_FAILED_JOBS);
when(anotherStatistics.getInstances()).thenReturn(ANOTHER_EXAMPLE_INSTANCES);
when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID);
when(anotherStatistics.getName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME);
when(anotherStatistics.getKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
when(anotherStatistics.getTenantId()).thenReturn(ANOTHER_EXAMPLE_TENANT_ID);
when(anotherStatistics.getVersionTag()).thenReturn(ANOTHER_EXAMPLE_VERSION_TAG);
IncidentStatistics anotherIncidentStaticits = mock(IncidentStatistics.class);
when(anotherIncidentStaticits.getIncidentType()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_TYPE);
when(anotherIncidentStaticits.getIncidentCount()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_COUNT);
List<IncidentStatistics> anotherExampleIncidentList = new ArrayList<IncidentStatistics>();
anotherExampleIncidentList.add(anotherIncidentStaticits);
when(anotherStatistics.getIncidentStatistics()).thenReturn(anotherExampleIncidentList);
List<ProcessDefinitionStatistics> processDefinitionResults = new ArrayList<ProcessDefinitionStatistics>();
processDefinitionResults.add(statistics);
processDefinitionResults.add(anotherStatistics);
return processDefinitionResults;
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingIncidentsAndFailedJobsWithoutProcessInstanceAuthorizations.
// including incidents and failed jobs ///////////////////////////////////////////////////////////////
public void testQueryIncludingIncidentsAndFailedJobsWithoutProcessInstanceAuthorizations() {
// given
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
// when
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeIncidents().includeFailedJobs().list();
// then
assertEquals(2, statistics.size());
ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
verifyStatisticsResult(oneIncidentProcessStatistics, 3, 3, 3);
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics 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.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingFailedJobsWithoutProcessInstanceAuthorizations.
// including failed jobs ////////////////////////////////////////////////////////////
public void testQueryIncludingFailedJobsWithoutProcessInstanceAuthorizations() {
// given
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
// when
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().list();
// then
assertEquals(2, statistics.size());
ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
verifyStatisticsResult(oneIncidentProcessStatistics, 3, 3, 0);
}
use of org.camunda.bpm.engine.management.ProcessDefinitionStatistics in project camunda-bpm-platform by camunda.
the class ProcessDefinitionStatisticsAuthorizationTest method testQueryIncludingInstancesWithoutProcessInstanceAuthorizations.
// including instances //////////////////////////////////////////////////////////////
public void testQueryIncludingInstancesWithoutProcessInstanceAuthorizations() {
// given
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
// when
List<ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().list();
// then
assertEquals(2, statistics.size());
ProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);
verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);
ProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);
verifyStatisticsResult(oneIncidentProcessStatistics, 3, 0, 0);
}
Aggregations