Implementing the initial step
Last updated
Last updated
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.
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 :
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.
Notice that we test there is not already a calculated attribute for that person with the same key
Select the field "quoteDate" :
and add a field and select birthdate. Select literal value.
And select a date as for the quote date but on same day (here June 30th? then add a expectatation by clicking on the Cross near Expect
Then click the "Run scenario" button twice and you should see the screeen as follows
First add the two classes on which we shall apply the rule. Then we should create the rule like that.