Esempio n. 1
0
        public virtual void testIfPartEvaluatesDecision()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();

            string humanTask1 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().Id;

            caseService.completeCaseExecution(humanTask1);

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.CaseDefinitionId).singleResult();

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            string activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            // references to case instance should be set since the decision is evaluated while executing a case instance
            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(caseDefinition.Key));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(caseDefinition.Id));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(caseInstance.Id));
            assertThat(historicDecisionInstance.ActivityId, @is("PI_HumanTask_1"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));
            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 2
0
        public virtual void testCaseDecisionInstanceProperties()
        {
            CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.CaseDefinitionId).singleResult();

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            string activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_DecisionTask_1").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));

            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(caseDefinition.Key));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(caseDefinition.Id));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(caseInstance.Id));

            assertThat(historicDecisionInstance.ActivityId, @is("PI_DecisionTask_1"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));

            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 3
0
        public virtual void testDecisionEvaluatedWithDecisionService()
        {
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["input1"] = "test";
            decisionService.evaluateDecisionTableByKey(DECISION_DEFINITION_KEY, variables);

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
            // references to process instance should be null since the decision is not evaluated while executing a process instance
            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.ActivityId, @is(nullValue()));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(nullValue()));
            // the user should be null since no user was authenticated during evaluation
            assertThat(historicDecisionInstance.UserId, @is(nullValue()));
        }
Esempio n. 4
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()));
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
        public virtual void testCompoundDecisionOutputInstances()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeOutputs().singleResult();
            IList <HistoricDecisionOutputInstance> outputs    = historicDecisionInstance.Outputs;

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

            HistoricDecisionOutputInstance firstOutput = outputs[0];

            assertThat(firstOutput.ClauseId, @is("out1"));
            assertThat(firstOutput.RuleId, @is("rule1"));
            assertThat(firstOutput.RuleOrder, @is(1));
            assertThat(firstOutput.VariableName, @is("result1"));
            assertThat(firstOutput.Value, @is((object)"okay"));

            HistoricDecisionOutputInstance secondOutput = outputs[1];

            assertThat(secondOutput.ClauseId, @is("out2"));
            assertThat(secondOutput.RuleId, @is("rule1"));
            assertThat(secondOutput.RuleOrder, @is(1));
            assertThat(secondOutput.VariableName, @is("result2"));
            assertThat(secondOutput.Value, @is((object)"not okay"));
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void evaluateDecisionWithDecisionService()
        public virtual void evaluateDecisionWithDecisionService()
        {
            runtimeService.startProcessInstanceByKey("testProcess", Variables.createVariables().putValue("input1", null).putValue("myBean", new DecisionServiceDelegate()));

            ProcessInstance   processInstance      = runtimeService.createProcessInstanceQuery().singleResult();
            ProcessDefinition processDefinition    = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.ProcessDefinitionId).singleResult();
            string            decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            // references to process instance should be set since the decision is evaluated while executing a process instance
            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(processDefinition.Key));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(processDefinition.Id));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(processInstance.Id));
            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.ActivityId, @is(activityId));
            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 8
0
        public virtual void decisionOutputInstanceProperties()
        {
            // given start process and evaluate decision
            VariableMap variables = Variables.createVariables();

            variables.put("input1", null);
            runtimeService.startProcessInstanceByKey("testProcess", variables);

            // when
            IList <HistoricDecisionInstance> decisionInstances = optimizeService.getHistoricDecisionInstances(pastDate(), null, 10);

            // then
            assertThat(decisionInstances.Count, @is(1));
            HistoricDecisionInstance decisionInstance      = decisionInstances[0];
            IList <HistoricDecisionOutputInstance> outputs = decisionInstance.Outputs;

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

            HistoricDecisionOutputInstance output = outputs[0];

            assertThat(output.DecisionInstanceId, @is(decisionInstance.Id));
            assertThat(output.ClauseId, @is("out"));
            assertThat(output.ClauseName, @is("output"));

            assertThat(output.RuleId, @is("rule"));
            assertThat(output.RuleOrder, @is(1));

            assertThat(output.VariableName, @is("result"));
        }
Esempio n. 9
0
        private void assertThatDecisionsHaveAllImportantInformation(IList <HistoricDecisionInstance> decisionInstances)
        {
            assertThat(decisionInstances.Count, @is(1));
            HistoricDecisionInstance decisionInstance = decisionInstances[0];


            assertThat(decisionInstance, notNullValue());
            assertThat(decisionInstance.ProcessDefinitionKey, @is("testProcess"));
            assertThat(decisionInstance.ProcessDefinitionId, notNullValue());
            assertThat(decisionInstance.DecisionDefinitionId, notNullValue());
            assertThat(decisionInstance.DecisionDefinitionKey, @is("testDecision"));
            assertThat(decisionInstance.DecisionDefinitionName, @is("sample decision"));

            assertThat(decisionInstance.ActivityId, @is("task"));
            assertThat(decisionInstance.ActivityInstanceId, notNullValue());

            assertThat(decisionInstance.ProcessInstanceId, @is(notNullValue()));
            assertThat(decisionInstance.RootProcessInstanceId, @is(notNullValue()));

            assertThat(decisionInstance.CaseDefinitionKey, @is(nullValue()));
            assertThat(decisionInstance.CaseDefinitionId, @is(nullValue()));

            assertThat(decisionInstance.CaseInstanceId, @is(nullValue()));

            assertThat(decisionInstance.RootDecisionInstanceId, @is(nullValue()));
            assertThat(decisionInstance.DecisionRequirementsDefinitionId, @is(nullValue()));
            assertThat(decisionInstance.DecisionRequirementsDefinitionKey, @is(nullValue()));

            assertThat(decisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 10
0
        public virtual void testListJsonProperty()
        {
            JsonListSerializable <string> list = new JsonListSerializable <string>();

            list.addElement("foo");

            ObjectValue objectValue = Variables.objectValue(list).serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME).create();

            VariableMap variables = Variables.createVariables().putValueTyped("input1", objectValue);

            decisionService.evaluateDecisionTableByKey("testDecision", variables);

            HistoricDecisionInstance testDecision = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey("testDecision").includeInputs().includeOutputs().singleResult();

            assertNotNull(testDecision);

            IList <HistoricDecisionInputInstance> inputs = testDecision.Inputs;

            assertEquals(1, inputs.Count);

            HistoricDecisionInputInstance inputInstance = inputs[0];

            assertEquals(list.ListProperty, inputInstance.Value);

            IList <HistoricDecisionOutputInstance> outputs = testDecision.Outputs;

            assertEquals(1, outputs.Count);

            HistoricDecisionOutputInstance outputInstance = outputs[0];

            assertEquals(list.ListProperty, outputInstance.Value);
        }
Esempio n. 11
0
        public virtual void testCaseDecisionEvaluatedWithDecisionServiceInsideDelegate()
        {
            CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.CaseDefinitionId).singleResult();

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            string activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            // references to case instance should be set since the decision is evaluated while executing a case instance
            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(caseDefinition.Key));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(caseDefinition.Id));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(caseInstance.Id));
            assertThat(historicDecisionInstance.ActivityId, @is("PI_HumanTask_1"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));
            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 12
0
        public virtual void testDecisionInstanceProperties()
        {
            startProcessInstanceAndEvaluateDecision();

            ProcessInstance   processInstance      = runtimeService.createProcessInstanceQuery().singleResult();
            ProcessDefinition processDefinition    = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.ProcessDefinitionId).singleResult();
            string            decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;
            string            activityInstanceId   = historyService.createHistoricActivityInstanceQuery().activityId("task").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(processDefinition.Key));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(processDefinition.Id));

            assertThat(historicDecisionInstance.ProcessInstanceId, @is(processInstance.Id));

            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(nullValue()));

            assertThat(historicDecisionInstance.CaseInstanceId, @is(nullValue()));

            assertThat(historicDecisionInstance.ActivityId, @is("task"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));

            assertThat(historicDecisionInstance.RootDecisionInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.DecisionRequirementsDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.DecisionRequirementsDefinitionKey, @is(nullValue()));

            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Esempio n. 13
0
        public static HistoricDecisionInstanceDto fromHistoricDecisionInstance(HistoricDecisionInstance historicDecisionInstance)
        {
            HistoricDecisionInstanceDto dto = new HistoricDecisionInstanceDto();

            dto.id = historicDecisionInstance.Id;
            dto.decisionDefinitionId   = historicDecisionInstance.DecisionDefinitionId;
            dto.decisionDefinitionKey  = historicDecisionInstance.DecisionDefinitionKey;
            dto.decisionDefinitionName = historicDecisionInstance.DecisionDefinitionName;
            dto.evaluationTime         = historicDecisionInstance.EvaluationTime;
            dto.removalTime            = historicDecisionInstance.RemovalTime;
            dto.processDefinitionId    = historicDecisionInstance.ProcessDefinitionId;
            dto.processDefinitionKey   = historicDecisionInstance.ProcessDefinitionKey;
            dto.processInstanceId      = historicDecisionInstance.ProcessInstanceId;
            dto.caseDefinitionId       = historicDecisionInstance.CaseDefinitionId;
            dto.caseDefinitionKey      = historicDecisionInstance.CaseDefinitionKey;
            dto.caseInstanceId         = historicDecisionInstance.CaseInstanceId;
            dto.activityId             = historicDecisionInstance.ActivityId;
            dto.activityInstanceId     = historicDecisionInstance.ActivityInstanceId;
            dto.userId                            = historicDecisionInstance.UserId;
            dto.collectResultValue                = historicDecisionInstance.CollectResultValue;
            dto.rootDecisionInstanceId            = historicDecisionInstance.RootDecisionInstanceId;
            dto.rootProcessInstanceId             = historicDecisionInstance.RootProcessInstanceId;
            dto.decisionRequirementsDefinitionId  = historicDecisionInstance.DecisionRequirementsDefinitionId;
            dto.decisionRequirementsDefinitionKey = historicDecisionInstance.DecisionRequirementsDefinitionKey;
            dto.tenantId                          = historicDecisionInstance.TenantId;

            try
            {
                IList <HistoricDecisionInputInstanceDto> inputs = new List <HistoricDecisionInputInstanceDto>();
                foreach (HistoricDecisionInputInstance input in historicDecisionInstance.Inputs)
                {
                    HistoricDecisionInputInstanceDto inputDto = HistoricDecisionInputInstanceDto.fromHistoricDecisionInputInstance(input);
                    inputs.Add(inputDto);
                }
                dto.inputs = inputs;
            }
            catch (ProcessEngineException)
            {
                // no inputs fetched
            }

            try
            {
                IList <HistoricDecisionOutputInstanceDto> outputs = new List <HistoricDecisionOutputInstanceDto>();
                foreach (HistoricDecisionOutputInstance output in historicDecisionInstance.Outputs)
                {
                    HistoricDecisionOutputInstanceDto outputDto = HistoricDecisionOutputInstanceDto.fromHistoricDecisionOutputInstance(output);
                    outputs.Add(outputDto);
                }
                dto.outputs = outputs;
            }
            catch (ProcessEngineException)
            {
                // no outputs fetched
            }

            return(dto);
        }
Esempio n. 14
0
        public virtual void testCollectResultValue()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance.CollectResultValue, @is(notNullValue()));
            assertThat(historicDecisionInstance.CollectResultValue, @is(3.0));
        }
Esempio n. 15
0
        public virtual void testDecisionEvaluatedWithAuthenticatedUserFromCase()
        {
            identityService.AuthenticatedUserId = "demo";
            createCaseInstanceAndEvaluateDecision();

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            // the user should be null since decision was evaluated by the case
            assertThat(historicDecisionInstance.UserId, @is(nullValue()));
        }
Esempio n. 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetSingleHistoricDecisionInstanceWithDisabledCustomObjectDeserialization()
        public virtual void testGetSingleHistoricDecisionInstanceWithDisabledCustomObjectDeserialization()
        {
            historicInstanceMock = MockProvider.createMockHistoricDecisionInstanceWithInputsAndOutputs();
            when(historicQueryMock.singleResult()).thenReturn(historicInstanceMock);

            given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_DECISION_INSTANCE_ID).queryParam("disableCustomObjectDeserialization", true).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_SINGLE_DECISION_INSTANCE_URL);

            InOrder inOrder = inOrder(historicQueryMock);

            inOrder.verify(historicQueryMock).decisionInstanceId(MockProvider.EXAMPLE_HISTORIC_DECISION_INSTANCE_ID);
            inOrder.verify(historicQueryMock).disableCustomObjectDeserialization();
            inOrder.verify(historicQueryMock).singleResult();
        }
Esempio n. 17
0
        public virtual void testDecisionEvaluatedWithAuthenticatedUser()
        {
            identityService.AuthenticatedUserId = "demo";
            VariableMap variables = Variables.putValue("input1", "test");

            decisionService.evaluateDecisionTableByKey(DECISION_DEFINITION_KEY, variables);

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            // the user should be set since the decision was evaluated with the decision service
            assertThat(historicDecisionInstance.UserId, @is("demo"));
        }
Esempio n. 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpRuntimeData()
        public virtual void setUpRuntimeData()
        {
            historyServiceMock = mock(typeof(HistoryService));

            // runtime service
            when(processEngine.HistoryService).thenReturn(historyServiceMock);

            historicInstanceMock = MockProvider.createMockHistoricDecisionInstance();
            historicQueryMock    = mock(typeof(HistoricDecisionInstanceQuery), RETURNS_DEEP_STUBS);

            when(historyServiceMock.createHistoricDecisionInstanceQuery()).thenReturn(historicQueryMock);
            when(historicQueryMock.decisionInstanceId(anyString())).thenReturn(historicQueryMock);
            when(historicQueryMock.singleResult()).thenReturn(historicInstanceMock);
        }
Esempio n. 19
0
        public virtual void testDisableDecisionInputInstanceByteValue()
        {
            sbyte[] bytes = "object".GetBytes();
            startProcessInstanceAndEvaluateDecision(bytes);

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeInputs().disableBinaryFetching().singleResult();
            IList <HistoricDecisionInputInstance> inputs      = historicDecisionInstance.Inputs;

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

            HistoricDecisionInputInstance input = inputs[0];

            assertThat(input.TypeName, @is("bytes"));
            assertThat(input.Value, @is(nullValue()));
        }
Esempio n. 20
0
        public virtual void testDeleteHistoricDecisionInstanceByInstanceId()
        {
            // given
            startProcessInstanceAndEvaluateDecision();
            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY);

            assertThat(query.count(), @is(1L));
            HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();

            // when
            historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);

            // then
            assertThat(query.count(), @is(0L));
        }
Esempio n. 21
0
        public virtual void testDecisionInputInstanceProperties()
        {
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeInputs().singleResult();
            IList <HistoricDecisionInputInstance> inputs      = historicDecisionInstance.Inputs;

            assertThat(inputs, @is(notNullValue()));
            assertThat(inputs.Count, @is(1));

            HistoricDecisionInputInstance input = inputs[0];

            assertThat(input.DecisionInstanceId, @is(historicDecisionInstance.Id));
            assertThat(input.ClauseId, @is("in"));
            assertThat(input.ClauseName, @is("input"));
        }
Esempio n. 22
0
        public virtual void testMultipleDecisionInputInstances()
        {
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["input1"] = "a";
            variables["input2"] = 1;
            runtimeService.startProcessInstanceByKey("testProcess", variables);

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeInputs().singleResult();
            IList <HistoricDecisionInputInstance> inputs      = historicDecisionInstance.Inputs;

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

            assertThat(inputs[0].Value, @is((object)"a"));
            assertThat(inputs[1].Value, @is((object)1));
        }
Esempio n. 23
0
        public virtual void testDeleteHistoricDecisionInstanceByInstanceIdWithDeleteHistoryPermissionOnDecisionDefinition()
        {
            // given
            createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, DELETE_HISTORY, READ_HISTORY);
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();

            verifyQueryResults(query, 1);
            HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();

            // when
            historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);

            // then
            verifyQueryResults(query, 0);
        }
Esempio n. 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void deleteHistoricDecisionInstanceByInstanceIdWithAuthenticatedTenant()
        public virtual void deleteHistoricDecisionInstanceByInstanceIdWithAuthenticatedTenant()
        {
            // given
            testRule.deployForTenant(TENANT_ONE, DMN);
            evaluateDecisionTable(null);

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
            HistoricDecisionInstance      historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();

            // when
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
            historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);

            // then
            identityService.clearAuthentication();
            assertThat(query.count(), @is(0L));
        }
Esempio n. 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoricDecisionInputInstanceBinary()
        public virtual void testHistoricDecisionInputInstanceBinary()
        {
            testRule.deploy(DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN);

            startProcessInstanceAndEvaluateDecision(new JavaSerializable("foo"));

            HistoricDecisionInstance historicDecisionInstance    = engineRule.HistoryService.createHistoricDecisionInstanceQuery().includeInputs().singleResult();
            IList <HistoricDecisionInputInstance> inputInstances = historicDecisionInstance.Inputs;

            assertEquals(1, inputInstances.Count);

            string byteArrayValueId = ((HistoricDecisionInputInstanceEntity)inputInstances[0]).ByteArrayValueId;

            // when
            ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(byteArrayValueId));

            checkBinary(byteArrayEntity);
        }
Esempio n. 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failToDeleteHistoricDecisionInstanceByInstanceIdNoAuthenticatedTenants()
        public virtual void failToDeleteHistoricDecisionInstanceByInstanceIdNoAuthenticatedTenants()
        {
            // given
            testRule.deployForTenant(TENANT_ONE, DMN);
            evaluateDecisionTable(null);

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
            HistoricDecisionInstance      historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();

            // when
            identityService.setAuthentication("user", null, null);

            // then
            thrown.expect(typeof(ProcessEngineException));
            thrown.expectMessage("Cannot delete the historic decision instance");

            historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);
        }
Esempio n. 27
0
        public virtual object execute(CommandContext commandContext)
        {
            ensureNotNull("historicDecisionInstanceId", historicDecisionInstanceId);

            HistoricDecisionInstance historicDecisionInstance = commandContext.HistoricDecisionInstanceManager.findHistoricDecisionInstance(historicDecisionInstanceId);

            ensureNotNull("No historic decision instance found with id: " + historicDecisionInstanceId, "historicDecisionInstance", historicDecisionInstance);
            writeUserOperationLog(commandContext);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkDeleteHistoricDecisionInstance(historicDecisionInstance);
            }

            commandContext.HistoricDecisionInstanceManager.deleteHistoricDecisionInstanceByIds(Arrays.asList(historicDecisionInstanceId));

            return(null);
        }
Esempio n. 28
0
        public virtual void testDeleteDecisionInstanceById()
        {
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["input1"] = "test";
            decisionService.evaluateDecisionTableByKey(DECISION_DEFINITION_KEY, variables);

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);

            IList <UserOperationLogEntry> userOperationLogEntries = historyService.createUserOperationLogQuery().operationType(OPERATION_TYPE_DELETE_HISTORY).property("nrOfInstances").list();

            assertEquals(1, userOperationLogEntries.Count);

            UserOperationLogEntry entry = userOperationLogEntries[0];

            assertEquals("1", entry.NewValue);
            assertEquals(CATEGORY_OPERATOR, entry.Category);
        }
Esempio n. 29
0
        public virtual void decisionInputInstanceValue()
        {
            SimpleDateFormat sdf       = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
            DateTime         fixedDate = sdf.parse("01/01/2001 01:01:01.000");

            ClockUtil.CurrentTime = fixedDate;

            startProcessInstanceAndEvaluateDecision(inputValue);

            HistoricDecisionInstance historicDecisionInstance    = engineRule.HistoryService.createHistoricDecisionInstanceQuery().includeInputs().singleResult();
            IList <HistoricDecisionInputInstance> inputInstances = historicDecisionInstance.Inputs;

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

            HistoricDecisionInputInstance inputInstance = inputInstances[0];

            assertThat(inputInstance.TypeName, @is(valueType));
            assertThat(inputInstance.Value, @is(inputValue));
            assertThat(inputInstance.CreateTime, @is(fixedDate));
        }
Esempio n. 30
0
        public virtual void testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization()
        {
            // given
            createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ_HISTORY);
            startProcessInstanceAndEvaluateDecision();

            HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
            HistoricDecisionInstance      historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();

            try
            {
                // when
                historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.Id);
                fail("expect authorization exception");
            }
            catch (AuthorizationException e)
            {
                // then
                assertThat(e.Message, @is("The user with id 'test' does not have 'DELETE_HISTORY' permission on resource 'testDecision' of type 'DecisionDefinition'."));
            }
        }