Task 3: Customizing the Expected Results sheet
You add a new test in the Expected Results sheet.
About this task
Now that you have configured your BOM so that it generates the correct columns with meaningful names, you want to add some tests to the Expected Results sheet of the Excel scenario file.
You want to test:
- If the loan is approved.
- The first message that is displayed when you run the rules.
The Report class
contains a method that returns a collection of messages (java.util.List).
When using an Excel scenario file, you can only define tests that
verify what is contained in the collection, that is, regardless of
the position of the contained element in the collection. To be able
to test exactly what the first message in the collection is, you must
define a new method in the BOM.
In this task, you create a new column for the Expected Results sheet to test the first message.
You must create a virtual attribute and define a getter that returns only the first message.
Step 1: Creating an attribute for the first message
You create an attribute for the first message.
Procedure
- In the Rule Explorer, navigate to loanvalidation-rules > bom > model > loan.
-
Double-click the
Reportclass to open it in the BOM editor. - In the Members area, click New.
- In the New Member window, make sure the Attribute type is selected.
- In the Name field, enter firstMessage.
- In the Type field, enter java.lang.String, and then click Finish.
Step 2: Defining a getter for an attribute
You define a getter for the firstMessage attribute.
Procedure
Step 3: Checking the Expected Results sheet
You check that the first message column that is shown in the Expected Results sheet by generating the Excel scenario file template.
Procedure
What to do next
In the next task, you add a domain to the properties of the borrower and see how to maintain it in the scenario file.
