droolsonboarding
  • Introduction
  • Technical Materials
  • Overview
  • Drools tutorial
    • Installing Drools Tooling
    • Data Model used in the tutorial
    • Lesson 1 : Core concepts
    • Lesson 2 : binding
    • lesson 3 : Some more drools languages
    • lesson 4 : ruleflow
    • lesson 5 : Exercise
      • Requirements
  • BRMS tutorial
    • Organizational Unit And repository
    • Data Model
    • Business Requirements
    • Design
    • Implementing the Process Flow
    • Implementation technical parts
    • Implementing the initial step
    • Implementing standard price step
    • Implementing the Child over 3 years old is free promotion step
    • Implementing the Birthday promotion step
    • Implementing the Zurich reduction step
    • Implementing the final step
    • Conclusion
  • BRMS Runtime tutorial
    • Install needed tools to run the workbench
Powered by GitBook
On this page
  • Implementing the initial step
  • Test the initial step
  • Calculate person age

Was this helpful?

  1. BRMS tutorial

Implementing the initial step

PreviousImplementation technical partsNextImplementing standard price step

Last updated 5 years ago

Was this helpful?

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.

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.