Пример #1
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()));
        }
Пример #2
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);
        }
Пример #3
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"));
        }
Пример #4
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"));
        }
Пример #5
0
 public virtual void addOutput(HistoricDecisionOutputInstance decisionOutputInstance)
 {
     if (outputs == null)
     {
         outputs = new List <HistoricDecisionOutputInstance>();
     }
     outputs.Add(decisionOutputInstance);
 }
Пример #6
0
        public virtual void decisionOutputInstanceValue()
        {
            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().includeOutputs().singleResult();
            IList <HistoricDecisionOutputInstance> outputInstances = historicDecisionInstance.Outputs;

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

            HistoricDecisionOutputInstance outputInstance = outputInstances[0];

            assertThat(outputInstance.TypeName, @is(valueType));
            assertThat(outputInstance.Value, @is(inputValue));
            assertThat(outputInstance.CreateTime, @is(fixedDate));
        }
Пример #7
0
        public virtual void testDecisionOutputInstanceProperties()
        {
            startProcessInstanceAndEvaluateDecision();

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

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

            HistoricDecisionOutputInstance output = outputs[0];

            assertThat(output.DecisionInstanceId, @is(historicDecisionInstance.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"));
        }
Пример #8
0
 protected internal virtual bool isBinaryValue(HistoricDecisionOutputInstance decisionOutputInstance)
 {
     return(AbstractTypedValueSerializer.BINARY_VALUE_TYPES.Contains(decisionOutputInstance.TypeName));
 }
Пример #9
0
        public static HistoricDecisionOutputInstanceDto fromHistoricDecisionOutputInstance(HistoricDecisionOutputInstance historicDecisionOutputInstance)
        {
            HistoricDecisionOutputInstanceDto dto = new HistoricDecisionOutputInstanceDto();

            dto.id = historicDecisionOutputInstance.Id;
            dto.decisionInstanceId    = historicDecisionOutputInstance.DecisionInstanceId;
            dto.clauseId              = historicDecisionOutputInstance.ClauseId;
            dto.clauseName            = historicDecisionOutputInstance.ClauseName;
            dto.ruleId                = historicDecisionOutputInstance.RuleId;
            dto.ruleOrder             = historicDecisionOutputInstance.RuleOrder;
            dto.variableName          = historicDecisionOutputInstance.VariableName;
            dto.createTime            = historicDecisionOutputInstance.CreateTime;
            dto.removalTime           = historicDecisionOutputInstance.RemovalTime;
            dto.rootProcessInstanceId = historicDecisionOutputInstance.RootProcessInstanceId;

            if (string.ReferenceEquals(historicDecisionOutputInstance.ErrorMessage, null))
            {
                VariableValueDto.fromTypedValue(dto, historicDecisionOutputInstance.TypedValue);
            }
            else
            {
                dto.errorMessage = historicDecisionOutputInstance.ErrorMessage;
                dto.type         = VariableValueDto.toRestApiTypeName(historicDecisionOutputInstance.TypeName);
            }

            return(dto);
        }