public virtual void instancesFailedJobsAndIncidentsCountWithAuthenticatedTenant()
        {
            testRule.Deploy(failingProcess);

            startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY);

            testRule.ExecuteAvailableJobs();

            identityService.SetAuthentication("user", null, new List <string>()
            {
                TENANT_ONE
            });

            IList <IProcessDefinitionStatistics> processDefinitionsStatistics = managementService.CreateProcessDefinitionStatisticsQuery() /*.IncludeFailedJobs()*//*.IncludeIncidents()*/.ToList();

            // then
            Assert.AreEqual(1, processDefinitionsStatistics.Count);
            IProcessDefinitionStatistics processDefinitionStatistics = processDefinitionsStatistics[0];

            Assert.AreEqual(2, processDefinitionStatistics.Instances);
            Assert.AreEqual(2, processDefinitionStatistics.FailedJobs);

            IList <IIncidentStatistics> incidentStatistics = processDefinitionStatistics.IncidentStatistics;

            Assert.AreEqual(1, incidentStatistics.Count);
            Assert.AreEqual(2, incidentStatistics[0].IncidentCount);
        }
Example #2
0
        // including incidents and failed jobs ///////////////////////////////////////////////////////////////

        public virtual 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(Resources.ProcessDefinition, AuthorizationFields.Any, userId, Permissions.Read);

            // when
            IList <IProcessDefinitionStatistics> statistics =
                managementService.CreateProcessDefinitionStatisticsQuery() /*.IncludeIncidents()*//*.IncludeFailedJobs()*/
                .ToList();

            // then
            Assert.AreEqual(2, statistics.Count);

            IProcessDefinitionStatistics oneTaskProcessStatistics = getStatisticsByKey(statistics, ONE_TASK_PROCESS_KEY);

            verifyStatisticsResult(oneTaskProcessStatistics, 2, 0, 0);

            IProcessDefinitionStatistics oneIncidentProcessStatistics = getStatisticsByKey(statistics, ONE_INCIDENT_PROCESS_KEY);

            verifyStatisticsResult(oneIncidentProcessStatistics, 3, 3, 3);
        }
        public virtual void testProcessDefinitionStatisticsQueryWithIncidentsWithoutFailedJobs()
        {
            runtimeService.StartProcessInstanceByKey("callExampleSubProcess");

            ExecuteAvailableJobs();

            var statistics = managementService.CreateProcessDefinitionStatisticsQuery()
                             /*.IncludeIncidents()*/
                             /*.IncludeFailedJobs()*/

                             .ToList();

            Assert.AreEqual(2, statistics.Count);

            IProcessDefinitionStatistics callExampleSubProcessStaticstics = null;
            IProcessDefinitionStatistics exampleSubProcessStaticstics     = null;

            foreach (var current in statistics)
            {
                if (current.Key.Equals("callExampleSubProcess"))
                {
                    callExampleSubProcessStaticstics = current;
                }
                else if (current.Key.Equals("ExampleProcess"))
                {
                    exampleSubProcessStaticstics = current;
                }
                else
                {
                    Assert.Fail(current.Key + " was not expected.");
                }
            }

            Assert.NotNull(callExampleSubProcessStaticstics);
            Assert.NotNull(exampleSubProcessStaticstics);

            // "super" process definition
            Assert.AreEqual(1, callExampleSubProcessStaticstics.Instances);
            Assert.AreEqual(0, callExampleSubProcessStaticstics.FailedJobs);

            Assert.IsFalse(!callExampleSubProcessStaticstics.IncidentStatistics.Any());
            Assert.AreEqual(1, callExampleSubProcessStaticstics.IncidentStatistics.Count());

            var incidentStatistics = callExampleSubProcessStaticstics.IncidentStatistics[0];

            Assert.AreEqual(IncidentFields.FailedJobHandlerType, incidentStatistics.IncidentType);
            Assert.AreEqual(1, incidentStatistics.IncidentCount);

            // "called" process definition
            Assert.AreEqual(1, exampleSubProcessStaticstics.Instances);
            Assert.AreEqual(1, exampleSubProcessStaticstics.FailedJobs);

            Assert.IsFalse(!exampleSubProcessStaticstics.IncidentStatistics.Any());
            Assert.AreEqual(1, exampleSubProcessStaticstics.IncidentStatistics.Count());

            incidentStatistics = exampleSubProcessStaticstics.IncidentStatistics[0];
            Assert.AreEqual(IncidentFields.FailedJobHandlerType, incidentStatistics.IncidentType);
            Assert.AreEqual(1, incidentStatistics.IncidentCount);
        }
Example #4
0
        protected internal virtual void verifyStatisticsResult(IProcessDefinitionStatistics statistics, int instances, int failedJobs, int incidents)
        {
            Assert.AreEqual(instances, statistics.Instances, "Instances");
            Assert.AreEqual(failedJobs, statistics.FailedJobs, "Failed Jobs");

            IList <IIncidentStatistics> incidentStatistics = statistics.IncidentStatistics;

            if (incidents == 0)
            {
                Assert.True(incidentStatistics.Count == 0, "Incidents supposed to be empty");
            }
            else
            {
                // the test does have only one type of incidents
                Assert.AreEqual(incidents, incidentStatistics[0].IncidentCount, "Incidents");
            }
        }
Example #5
0
        public virtual void testQueryWithReadPermissionOnOneTaskProcess()
        {
            // given
            createGrantAuthorization(Resources.ProcessDefinition, ONE_TASK_PROCESS_KEY, userId, Permissions.Read);

            // when
            IQueryable <IProcessDefinitionStatistics> query = managementService.CreateProcessDefinitionStatisticsQuery();

            // then
            //verifyQueryResults(query, 1);

            IProcessDefinitionStatistics statistics = query.First();

            Assert.AreEqual(ONE_TASK_PROCESS_KEY, statistics.Key);
            Assert.AreEqual(0, statistics.Instances);
            Assert.AreEqual(0, statistics.FailedJobs);
            Assert.True(!DynamicQueryable.Any(statistics.IncidentStatistics));
        }