Implementing the initial step

Implementing the initial step

Then you shall obtain the rule as follows. Notice that the stringValue of the calculatedAttribute as a formula. So you should select the formula not a litteral. And also that we had to create a binding varialble "bd" for attribute birthdate of call Person.

Notice that we have to add to the list of calculated attribute of the person and then tell the rule engine the list was updated.

Test the initial step

The workbench allows to test the rule we do. Create a new item of type "Test scenario" like follows :

Click on the "Given" Cross and add a new fact as follows :

Then click on the "Add Field" text.

Click on the "Literal value" button

As the attribute is of type date, you can select a date with the date picker.

Select a date and then add another instance of type Person

Add a fact of type CalculatedAttribute

and Click on the "A fact of type... " Then chose the StringValue field

And then enter the value true

And as the rule we want to test is in ruleflow group init. Click on the cross near the "Given" cross and enter "init" in the activate rule flow group part.

The test scenario should then look like this :

Calculate person age

We shall calculate the person age based on his birthday and the curDay attribute of the quote. At the same time, we shall initialize the price attribute with a BigDecimal. in the function.drl, add the "import java.math.BigDecimal"

We added two options : the ruleflow group.

Then we can create a test scenario to verify our rule.

Last updated