Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createMonitorJobByIdsAndQuery()
        public virtual void createMonitorJobByIdsAndQuery()
        {
            // given
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
            Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);

            // when
            helper.executeSeedJob(batch);

            // then the seed job definition still exists but the seed job is removed
            JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);

            assertNotNull(seedJobDefinition);

            Job seedJob = helper.getSeedJob(batch);

            assertNull(seedJob);

            // and a monitor job definition and job exists
            JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);

            assertNotNull(monitorJobDefinition);

            Job monitorJob = helper.getMonitorJob(batch);

            assertNotNull(monitorJob);
        }
Ejemplo n.º 2
0
        public virtual void testDecisionInstancePropertiesOfDecisionLiteralExpression()
        {
            DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();

            decisionService.evaluateDecisionByKey("decision").variables(Variables.createVariables().putValue("sum", 2205)).evaluate();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs();

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

            HistoricDecisionInstance historicDecisionInstance = query.singleResult();

            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinition.Id));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is("decision"));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("Decision with Literal Expression"));
            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));

            assertThat(historicDecisionInstance.Inputs.Count, @is(0));

            IList <HistoricDecisionOutputInstance> outputs = historicDecisionInstance.Outputs;

            assertThat(outputs.Count, @is(1));

            HistoricDecisionOutputInstance output = outputs[0];

            assertThat(output.VariableName, @is("result"));
            assertThat(output.TypeName, @is("string"));
            assertThat((string)output.Value, @is("ok"));

            assertThat(output.ClauseId, @is(nullValue()));
            assertThat(output.ClauseName, @is(nullValue()));
            assertThat(output.RuleId, @is(nullValue()));
            assertThat(output.RuleOrder, @is(nullValue()));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void deleteHistoricDecisionInstanceByInstanceIdWithDisabledTenantCheck()
        public virtual void deleteHistoricDecisionInstanceByInstanceIdWithDisabledTenantCheck()
        {
            // given
            testRule.deployForTenant(TENANT_ONE, DMN);
            testRule.deployForTenant(TENANT_TWO, DMN);

            evaluateDecisionTable(TENANT_ONE);
            evaluateDecisionTable(TENANT_TWO);

            HistoricDecisionInstanceQuery    query = historyService.createHistoricDecisionInstanceQuery();
            IList <HistoricDecisionInstance> historicDecisionInstances = query.includeInputs().includeOutputs().list();

            assertThat(historicDecisionInstances.Count, @is(2));

            // when user has no authorization
            identityService.setAuthentication("user", null, null);
            // and when tenant check is disabled
            processEngineConfiguration.TenantCheckEnabled = false;
            // and when all decision instances are deleted
            foreach (HistoricDecisionInstance @in in historicDecisionInstances)
            {
                historyService.deleteHistoricDecisionInstanceByInstanceId(@in.Id);
            }

            // then
            identityService.clearAuthentication();
            assertThat(query.count(), @is(0L));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIncludeInputsAndOutputs()
        public virtual void testIncludeInputsAndOutputs()
        {
            mockedQuery = setUpMockHistoricDecisionInstanceQuery(Collections.singletonList(MockProvider.createMockHistoricDecisionInstanceWithInputsAndOutputs()));

            string decisionDefinitionId = MockProvider.EXAMPLE_DECISION_DEFINITION_ID;

            Response response = given().queryParam("decisionDefinitionId", decisionDefinitionId).queryParam("includeInputs", true).queryParam("includeOutputs", true).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_DECISION_INSTANCE_RESOURCE_URL);

            InOrder inOrder = inOrder(mockedQuery);

            inOrder.verify(mockedQuery).decisionDefinitionId(decisionDefinitionId);
            inOrder.verify(mockedQuery).includeInputs();
            inOrder.verify(mockedQuery).includeOutputs();
            inOrder.verify(mockedQuery).list();

            string         content   = response.asString();
            IList <string> instances = from(content).getList("");

            assertEquals(1, instances.Count);
            Assert.assertNotNull(instances[0]);

            IList <IDictionary <string, object> > returnedInputs  = from(content).getList("[0].inputs");
            IList <IDictionary <string, object> > returnedOutputs = from(content).getList("[0].outputs");

            assertThat(returnedInputs, @is(notNullValue()));
            assertThat(returnedOutputs, @is(notNullValue()));

            verifyHistoricDecisionInputInstances(returnedInputs);
            verifyHistoricDecisionOutputInstances(returnedOutputs);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void executeBatch()
        public virtual void executeBatch()
        {
            // given
            authRule.init(scenario).withUser("userId").start();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);

            Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);

            if (batch != null)
            {
                Job job = managementService.createJobQuery().jobDefinitionId(batch.SeedJobDefinitionId).singleResult();

                // seed job
                managementService.executeJob(job.Id);

                foreach (Job pending in managementService.createJobQuery().jobDefinitionId(batch.BatchJobDefinitionId).list())
                {
                    managementService.executeJob(pending.Id);
                }
            }
            // then
            if (authRule.assertScenario(scenario))
            {
                assertEquals("userId", batch.CreateUserId);
            }
        }
Ejemplo n.º 6
0
        public virtual void testDecisionInstancePropertiesOfDrdDecision()
        {
            decisionService.evaluateDecisionTableByKey("dish-decision").variables(Variables.createVariables().putValue("temperature", 21).putValue("dayType", "Weekend")).evaluate();

            DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

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

            HistoricDecisionInstance rootHistoricDecisionInstance      = query.decisionDefinitionKey("dish-decision").singleResult();
            HistoricDecisionInstance requiredHistoricDecisionInstance1 = query.decisionDefinitionKey("season").singleResult();
            HistoricDecisionInstance requiredHistoricDecisionInstance2 = query.decisionDefinitionKey("guestCount").singleResult();

            assertThat(rootHistoricDecisionInstance.RootDecisionInstanceId, @is(nullValue()));
            assertThat(rootHistoricDecisionInstance.DecisionRequirementsDefinitionId, @is(decisionRequirementsDefinition.Id));
            assertThat(rootHistoricDecisionInstance.DecisionRequirementsDefinitionKey, @is(decisionRequirementsDefinition.Key));

            assertThat(requiredHistoricDecisionInstance1.RootDecisionInstanceId, @is(rootHistoricDecisionInstance.Id));
            assertThat(requiredHistoricDecisionInstance1.DecisionRequirementsDefinitionId, @is(decisionRequirementsDefinition.Id));
            assertThat(requiredHistoricDecisionInstance1.DecisionRequirementsDefinitionKey, @is(decisionRequirementsDefinition.Key));

            assertThat(requiredHistoricDecisionInstance2.RootDecisionInstanceId, @is(rootHistoricDecisionInstance.Id));
            assertThat(requiredHistoricDecisionInstance2.DecisionRequirementsDefinitionId, @is(decisionRequirementsDefinition.Id));
            assertThat(requiredHistoricDecisionInstance2.DecisionRequirementsDefinitionKey, @is(decisionRequirementsDefinition.Key));
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createDeletionJobsByIdsAndQuery()
        public virtual void createDeletionJobsByIdsAndQuery()
        {
            // given
            rule.ProcessEngineConfiguration.BatchJobsPerSeed = 5;

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);

            Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);

            JobDefinition seedJobDefinition     = helper.getSeedJobDefinition(batch);
            JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);

            // when
            helper.executeSeedJob(batch);

            // then
            IList <Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);

            assertEquals(5, deletionJobs.Count);

            foreach (Job deletionJob in deletionJobs)
            {
                assertEquals(deletionJobDefinition.Id, deletionJob.JobDefinitionId);
                assertEquals(currentTime, deletionJob.Duedate);
                assertNull(deletionJob.ProcessDefinitionId);
                assertNull(deletionJob.ProcessDefinitionKey);
                assertNull(deletionJob.ProcessInstanceId);
                assertNull(deletionJob.ExecutionId);
            }

            // and the seed job still exists
            Job seedJob = helper.getJobForDefinition(seedJobDefinition);

            assertNotNull(seedJob);
        }
Ejemplo n.º 8
0
        public virtual void testQueryByUserId()
        {
            evaluateDecisionWithAuthenticatedUser("demo");

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.userId("demo").count(), @is(1L));
        }
Ejemplo n.º 9
0
        public virtual CountResultDto queryHistoricDecisionInstancesCount(HistoricDecisionInstanceQueryDto queryDto)
        {
            HistoricDecisionInstanceQuery query = queryDto.toQuery(processEngine);

            long count = query.count();

            return(new CountResultDto(count));
        }
Ejemplo n.º 10
0
        public virtual void testQueryByCaseInstanceId()
        {
            CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.caseInstanceId(caseInstance.Id).count(), @is(1L));
        }
Ejemplo n.º 11
0
        public virtual void testQueryIncludeOutputsNoInput()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.includeOutputs().singleResult().Outputs.size(), @is(0));
        }
Ejemplo n.º 12
0
        public virtual void testQueryNoAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, null);

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.count(), @is(0L));
        }
Ejemplo n.º 13
0
        public virtual void testQueryByCaseDefinitionKey()
        {
            createCaseInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.caseDefinitionKey("case").count(), @is(1L));
        }
Ejemplo n.º 14
0
        public virtual void testQueryByDecisionDefinitionName()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.decisionDefinitionName("sample decision").count(), @is(1L));
            assertThat(query.decisionDefinitionName("other name").count(), @is(0L));
        }
Ejemplo n.º 15
0
        public virtual void testQueryByDecisionDefinitionKey()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.decisionDefinitionKey(DECISION_DEFINITION_KEY).count(), @is(1L));
            assertThat(query.decisionDefinitionKey("other key").count(), @is(0L));
        }
Ejemplo n.º 16
0
        public virtual void testQueryDisabledTenantCheck()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.count(), @is(2L));
        }
Ejemplo n.º 17
0
        public virtual void testQueryByDecisionRequirementsDefinitionKey()
        {
            decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue("temperature", 21).putValue("dayType", "Weekend")).evaluate();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.decisionRequirementsDefinitionKey("notExisting").count(), @is(0L));
            assertThat(query.decisionRequirementsDefinitionKey("dish").count(), @is(3L));
        }
Ejemplo n.º 18
0
        public virtual void testQueryByDecisionDefinitionNameLike()
        {
            startProcessInstanceAndEvaluateDecision();
            startProcessInstanceAndEvaluateDecisionWithUnderscore();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.decisionDefinitionNameLike("%ample dec%").count(), @is(1L));
            assertThat(query.decisionDefinitionNameLike("%ample\\_%").count(), @is(1L));
        }
Ejemplo n.º 19
0
        public virtual void testQueryAuthenticatedTenants()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.count(), @is(2L));
            assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L));
            assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L));
        }
Ejemplo n.º 20
0
        public virtual void testQueryByTenantId()
        {
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().tenantIdIn(TENANT_ONE);

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

            query = historyService.createHistoricDecisionInstanceQuery().tenantIdIn(TENANT_TWO);

            assertThat(query.count(), @is(1L));
        }
Ejemplo n.º 21
0
        public virtual void testQueryPaging()
        {
            startProcessInstanceAndEvaluateDecision();
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.listPage(0, 2).size(), @is(2));
            assertThat(query.listPage(1, 1).size(), @is(1));
        }
Ejemplo n.º 22
0
        public virtual void testQueryIncludeOutputsForNonExistingDecision()
        {
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().includeOutputs();

            assertThat(query.singleResult(), @is(nullValue()));

            startProcessInstanceAndEvaluateDecision();

            assertThat(query.decisionInstanceId("nonExisting").singleResult(), @is(nullValue()));
        }
Ejemplo n.º 23
0
        public virtual void testQueryByRootDecisionInstancesOnly()
        {
            decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue("temperature", 21).putValue("dayType", "Weekend")).evaluate();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.count(), @is(3L));
            assertThat(query.rootDecisionInstancesOnly().count(), @is(1L));
            assertThat(query.rootDecisionInstancesOnly().singleResult().DecisionDefinitionKey, @is(DISH_DECISION));
        }
Ejemplo n.º 24
0
        public virtual void testQueryByActivityId()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.activityIdIn("task").count(), @is(1L));
            assertThat(query.activityIdIn("other activity").count(), @is(0L));
            assertThat(query.activityIdIn("task", "other activity").count(), @is(1L));
        }
Ejemplo n.º 25
0
        public virtual void testQueryWithoutAuthorization()
        {
            // given
            startProcessInstanceAndEvaluateDecision();

            // when
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            // then
            verifyQueryResults(query, 0);
        }
Ejemplo n.º 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBatchDeletionByIdsAndQuery()
        public virtual void createBatchDeletionByIdsAndQuery()
        {
            // given
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);

            // when
            Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);

            // then
            assertBatchCreated(batch, 10);
        }
Ejemplo n.º 27
0
        protected internal virtual HistoricDecisionInstanceQuery setUpMockHistoricDecisionInstanceQuery(IList <HistoricDecisionInstance> mockedHistoricDecisionInstances)
        {
            HistoricDecisionInstanceQuery mockedHistoricDecisionInstanceQuery = mock(typeof(HistoricDecisionInstanceQuery));

            when(mockedHistoricDecisionInstanceQuery.list()).thenReturn(mockedHistoricDecisionInstances);
            when(mockedHistoricDecisionInstanceQuery.count()).thenReturn((long)mockedHistoricDecisionInstances.Count);

            when(processEngine.HistoryService.createHistoricDecisionInstanceQuery()).thenReturn(mockedHistoricDecisionInstanceQuery);

            return(mockedHistoricDecisionInstanceQuery);
        }
Ejemplo n.º 28
0
        public virtual void testQueryByDecisionDefinitionId()
        {
            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.decisionDefinitionId(decisionDefinitionId).count(), @is(1L));
            assertThat(query.decisionDefinitionId("other id").count(), @is(0L));
        }
Ejemplo n.º 29
0
        public virtual void testQueryByProcessDefinitionKey()
        {
            string processDefinitionKey = repositoryService.createProcessDefinitionQuery().singleResult().Key;

            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.processDefinitionKey(processDefinitionKey).count(), @is(1L));
            assertThat(query.processDefinitionKey("other process").count(), @is(0L));
        }
Ejemplo n.º 30
0
        public virtual void testQueryByProcessInstanceId()
        {
            startProcessInstanceAndEvaluateDecision();

            string processInstanceId = runtimeService.createProcessInstanceQuery().singleResult().Id;

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            assertThat(query.processInstanceId(processInstanceId).count(), @is(1L));
            assertThat(query.processInstanceId("other process").count(), @is(0L));
        }