Example #1
0
        private void setupProcessDefinitionStatisticsMock()
        {
            IList <ProcessDefinitionStatistics> mocks = MockProvider.createMockProcessDefinitionStatistics();

            processDefinitionStatisticsQueryMock = mock(typeof(ProcessDefinitionStatisticsQuery));
            when(processDefinitionStatisticsQueryMock.list()).thenReturn(mocks);
            when(processEngine.ManagementService.createProcessDefinitionStatisticsQuery()).thenReturn(processDefinitionStatisticsQueryMock);
        }
Example #2
0
        public virtual void testQueryAuthenticatedTenantsForProcessDefinitionStatistics()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));

            ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();

            assertThat(query.count(), @is(3L));

            ISet <string> tenantIds = collectDefinitionTenantIds(query.list());

            assertThat(tenantIds.Count, @is(3));
            assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO));
        }
Example #3
0
        public virtual void testQueryNoAuthenticatedTenantsForProcessDefinitionStatistics()
        {
            identityService.setAuthentication("user", null, null);

            ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();

            assertThat(query.count(), @is(1L));

            ISet <string> tenantIds = collectDefinitionTenantIds(query.list());

            assertThat(tenantIds.Count, @is(1));
            assertThat(tenantIds.GetEnumerator().next(), @is(nullValue()));
        }
Example #4
0
        public virtual IList <StatisticsResultDto> getStatistics(bool?includeFailedJobs, bool?includeRootIncidents, bool?includeIncidents, string includeIncidentsForType)
        {
            if (includeIncidents != null && !string.ReferenceEquals(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 && !string.ReferenceEquals(includeIncidentsForType, null))
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set.");
            }

            ManagementService mgmtService          = ProcessEngine.ManagementService;
            ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();

            if (includeFailedJobs != null && includeFailedJobs)
            {
                query.includeFailedJobs();
            }

            if (includeIncidents != null && includeIncidents)
            {
                query.includeIncidents();
            }
            else if (!string.ReferenceEquals(includeIncidentsForType, null))
            {
                query.includeIncidentsForType(includeIncidentsForType);
            }
            else if (includeRootIncidents != null && includeRootIncidents)
            {
                query.includeRootIncidents();
            }

            IList <ProcessDefinitionStatistics> queryResults = query.list();

            IList <StatisticsResultDto> results = new List <StatisticsResultDto>();

            foreach (ProcessDefinitionStatistics queryResult in queryResults)
            {
                StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
                results.Add(dto);
            }

            return(results);
        }
Example #5
0
        public virtual void testQueryDisabledTenantCheckForProcessDefinitionStatistics()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();

            assertThat(query.count(), @is(3L));

            ISet <string> tenantIds = collectDefinitionTenantIds(query.list());

            assertThat(tenantIds.Count, @is(3));
            assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO));
        }
Example #6
0
        public virtual void testQueryWithReadPermissionOnAnyProcessDefinition()
        {
            // given
            createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);

            // when
            ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();

            // then
            verifyQueryResults(query, 2);

            IList <ProcessDefinitionStatistics> statistics = query.list();

            foreach (ProcessDefinitionStatistics result in statistics)
            {
                verifyStatisticsResult(result, 0, 0, 0);
            }
        }