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
        // without running instances //////////////////////////////////////////////////////////

        public virtual void testQueryWithoutAuthorizations()
        {
            // given

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

            // then
            verifyQueryResults(query, 0);
        }
Example #3
0
        public virtual 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);
        }
Example #4
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 #5
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 #6
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 #7
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 #8
0
        public virtual 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.Key);
            assertEquals(0, statistics.Instances);
            assertEquals(0, statistics.FailedJobs);
            assertTrue(statistics.IncidentStatistics.Count == 0);
        }
Example #9
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);
            }
        }
Example #10
0
        // helper ///////////////////////////////////////////////////////////////////////////

        protected internal virtual void verifyQueryResults(ProcessDefinitionStatisticsQuery query, int countExpected)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: verifyQueryResults((org.camunda.bpm.engine.impl.AbstractQuery<?, ?>) query, countExpected);
            verifyQueryResults((AbstractQuery <object, ?>)query, countExpected);
        }