Exemple #1
0
        // deployment statistics query without process instance authorizations /////////////////////////////////////////////

        public virtual void testQueryWithoutAuthorization()
        {
            // given

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

            // then
            verifyQueryResults(query, 0);
        }
Exemple #2
0
        public virtual void testQueryWithMultiple()
        {
            // given
            createGrantAuthorization(DEPLOYMENT, firstDeploymentId, userId, READ);
            createGrantAuthorization(DEPLOYMENT, ANY, userId, READ);

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

            // then
            verifyQueryResults(query, 3);
        }
Exemple #3
0
        public virtual void testQueryAuthenticatedTenantForDeploymentStatistics()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));

            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

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

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

            assertThat(tenantIds.Count, @is(2));
            assertThat(tenantIds, hasItems(null, TENANT_ONE));
        }
Exemple #4
0
        public virtual void testQueryNoAuthenticatedTenantsForDeploymentStatistics()
        {
            identityService.setAuthentication("user", null, null);

            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

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

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

            assertThat(tenantIds.Count, @is(1));
            assertThat(tenantIds.GetEnumerator().next(), @is(nullValue()));
        }
Exemple #5
0
        public virtual void testQueryDisabledTenantCheckForDeploymentStatistics()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

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

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

            assertThat(tenantIds.Count, @is(3));
            assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO));
        }
Exemple #6
0
        public virtual void testQueryWithReadPermissionOnDeployment()
        {
            // given
            createGrantAuthorization(DEPLOYMENT, firstDeploymentId, userId, READ);

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

            // then
            verifyQueryResults(query, 1);

            DeploymentStatistics statistics = query.singleResult();

            verifyStatisticsResult(statistics, 0, 0, 0);
        }
Exemple #7
0
        public virtual void testQueryIncludingFailedJobsAndIncidentsWithReadInstancePermissionOnAnyProcessDefinition()
        {
            // given
            createGrantAuthorization(DEPLOYMENT, ANY, userId, READ);

            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);

            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);

            startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);

            createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery().includeFailedJobs().includeIncidents();

            // then
            IList <DeploymentStatistics> statistics = query.list();

            foreach (DeploymentStatistics deploymentStatistics in statistics)
            {
                string id = deploymentStatistics.Id;
                if (id.Equals(firstDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 3, 3, 3);
                }
                else if (id.Equals(secondDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 3, 0, 0);
                }
                else if (id.Equals(thirdDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 3, 0, 0);
                }
                else
                {
                    fail("Unexpected deployment");
                }
            }
        }
Exemple #8
0
        // deployment statistics query (including process instances) /////////////////////////////////////////////

        public virtual void testQueryWithReadPermissionOnProcessInstance()
        {
            // given
            createGrantAuthorization(DEPLOYMENT, ANY, userId, READ);

            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
            startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);

            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_START_PROCESS_KEY);

            startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
            startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
            string processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).Id;

            createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

            // then
            IList <DeploymentStatistics> statistics = query.list();

            foreach (DeploymentStatistics deploymentStatistics in statistics)
            {
                string id = deploymentStatistics.Id;
                if (id.Equals(firstDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 0, 0, 0);
                }
                else if (id.Equals(secondDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 0, 0, 0);
                }
                else if (id.Equals(thirdDeploymentId))
                {
                    verifyStatisticsResult(deploymentStatistics, 1, 0, 0);
                }
                else
                {
                    fail("Unexpected deployment");
                }
            }
        }
Exemple #9
0
        public virtual void testQueryWithReadPermissionOnAnyDeployment()
        {
            // given
            createGrantAuthorization(DEPLOYMENT, ANY, userId, READ);

            // when
            DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery();

            // then
            verifyQueryResults(query, 3);

            IList <DeploymentStatistics> result = query.list();

            foreach (DeploymentStatistics statistics in result)
            {
                verifyStatisticsResult(statistics, 0, 0, 0);
            }
        }
Exemple #10
0
        public virtual void testDeploymentStatisticsIgnoreReadInstance()
        {
            // given
            processEngineConfiguration.DisabledPermissions = Arrays.asList(READ_INSTANCE.name());

            runtimeService.startProcessInstanceByKey("timerBoundaryProcess");

            authRule.enableAuthorization(USER_ID);

            // when
            DeploymentStatisticsQuery query = engineRule.ManagementService.createDeploymentStatisticsQuery();

            // then
            IList <DeploymentStatistics> statistics = query.list();

            foreach (DeploymentStatistics deploymentStatistics in statistics)
            {
                assertEquals("Instances", 1, deploymentStatistics.Instances);
                assertEquals("Failed Jobs", 0, deploymentStatistics.FailedJobs);

                IList <IncidentStatistics> incidentStatistics = deploymentStatistics.IncidentStatistics;
                assertTrue("Incidents supposed to be empty", incidentStatistics.Count == 0);
            }
        }
Exemple #11
0
        // helper ///////////////////////////////////////////////////////////////////////////

        protected internal virtual void verifyQueryResults(DeploymentStatisticsQuery 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);
        }