Task 2: Customizing column headings

You give meaningful names to column headings.

About this task

In the BOM, the names of the constructor arguments are set by default to arg1, arg2, arg3, arg4, and arg5. The column headings in the Excel scenario file template correspond to the BOM object that you want to test. The required column headings are defined by the constructor arguments.

In this task, you give meaningful names to the constructor arguments so that they reflect the BOM object being tested. Then, you generate the Excel scenario file template to see the results.

Step 1: Modifying the names of the constructor parameters

You modify the names of the constructor parameters.

Procedure

  1. In the Rule Explorer, double-click the Borrower class (loanvalidation-rules > bom > model > loan > Borrower).
  2. In the Members area, double-click the Borrower (String, String, Date, String, int) constructor.
  3. Scroll to the BOM to XOM Mapping section. It is empty, so the constructor is described in the XOM.
  4. Open the loanvalidation-xom/src/loan/Borrower.java class. Scroll to the constructor to see the names of the arguments.
    Image shows the arguments.
  5. Switch to the model page to edit the Borrower BOM class
  6. In the Arguments area, double-click the arguments to edit them, and change them as follows:
    • arg1 to firstName
    • arg2 to lastName
    • arg3 to birthDate
    • arg4 to SSN
    • arg5 to creditScore

    The new name given to an argument corresponds to the attribute that it references. If the attributes are verbalized, the column headings are verbalized accordingly. For example, the attribute firstName is verbalized as first name and is shown as such in the Excel scenario file template.

  7. Save the changes.

Step 2: Adding a virtual attribute

You check the project again, and decide to add a virtual attribute for an intermediate value.

Procedure

  1. Check the project as shown Task 1. There is still an error.
  2. Select the error in the Testing and Simulation BOM Validation view. It says that the SSN arguments do not correspond to an attribute.
  3. Switch to the loanvalidation-xom/src/loan/Borrower.java file.
    You see that the string value SSN initializes an SSN attribute of the type SSN:

    this.SSN = new SSN(SSN);

    You see that the SSN class defines a toString method. You decide to create a virtual attribute, called SSNCode, to add the string value SSN in your BOM class.

  4. In the BOM editor, select the Class tab. In the Borrower class, click New in the Members part.
  5. In the Type part, keep Attribute selected. Enter SSNCode as the name, and java.lang.String as the type, and then click Finish.
  6. Double-click the new member SSNCode to edit it. Select Read Only in General Information.
  7. In the Member verbalization part, click Create a default verbalization.
  8. In the generated verbalization, click Edit the subject used in phrases.
  9. In the Edit Term wizard, change the Singular field from SSNCode to SSN code. This term is used as the column heading.
    Image shows term editor.
  10. Scroll to the BOM to XOM Mapping section.
    Add in the Getter part:

    return getSSN().toString();

  11. Select the Class tab, and in the members part, double-click the constructor with five arguments.
  12. In the Arguments, double-click SSN to change its value to SSNCode.
  13. Save your changes.
  14. Check the project again. Now it says that the loanvalidation-rule operation is compatible with testing and simulation.

Step 3: Generating the Excel scenario file template

To check that you have successfully renamed the column headings, generate the Excel scenario file template.

Procedure

  1. In the Rule Explorer, right-click the loanvalidation-rules project, and then click Testing and simulation > Generate Excel Scenario File Template.
    The Generate Excel Scenario File Template wizard opens.
  2. Make sure that the selected rule project is loanvalidation-rules, and then click Next.
  3. Make sure that the selected decision operation is loanvalidation-rules/loanvalidation-rulesOperation, and then click Next.
  4. Keep the default options as you did in the previous task.
  5. On the Expected Results page, click Finish because you do not need to include any tests for now.

    By default, the Excel scenario file template is generated in the loanvalidation-rules project. If the project does not show the Excel scenario file template, right-click the project and click Refresh.

  6. In the Rule Explorer, double-click testsuite.xlsx to open the file.

    The column headings displayed in bold are now first name, last name, birth date, SSN code, and credit score.

    Scenarios sheet
  7. Close testsuite.xlsx.

Step 4: Ignoring a column

All attributes that have a setter in the BOM is shown as optional in the generated Excel file. You remove the zip code column.

Procedure

  1. In the BOM editor, click the Class tab to open the Borrower class.
  2. In the Members area, double-click zipCode.
  3. In the General Information part of the editor, select Ignore for testing and simulation.
  4. Save the changes by using the save button in the Eclipse toolbar.
  5. Generate the Excel scenario file template as shown in Step 3.
    The zip code column no longer shows in the generated Excel file.

What to do next

In the next task, you add tests that are displayed in the Expected Results sheet.