Task 1: Selecting a constructor

You select the constructor that you want to use for the tests.

About this task

The Scenarios sheet of the Excel scenario file template contains both required and optional columns, which are defined by the ruleset input parameters. The BOM classes that make up the input parameters have constructors whose arguments correspond to the required columns in the Scenarios sheet. When there are several constructors for the same class, you must select the constructor that generates the correct columns.

In this task, you select a new constructor for the Borrower class that includes the same arguments as the original constructor, but with an additional creditScore argument.

Important:

If you have already imported the loanvalidation-xom and loanvalidation-rules project into your workspace, delete them or use a new workspace.

Step 1: Importing the start project

You import the start project.

Procedure

  1. Open the Samples Console in the en_US (American English) locale (see Running samples from the Samples Console).
  2. In the Samples and Tutorials view, navigate to Rule Designer > Tutorials > Configuring the BOM for Excel testing > start, and then click Import projects.

    The imported projects are displayed in the Rule Explorer:

    • The Java™ project loanvalidation-xom defines an execution object model (XOM).
    • The rule project loanvalidation-rules defines the business object model (BOM).

Step 2: Checking the project

You check the project.

Procedure

  1. In the Rule Explorer, right-click the loanvalidation-rules project, and then click Testing and simulation > Check Project.

    The Testing and Simulation BOM Validation view opens.

  2. Check that loanvalidation-rulesOperation is selected as the decision operation, and then click Finish.
    Close the dialog that shows one error.
  3. Select the error that is displayed in the Testing and Simulation BOM view.
    It shows a problem for the constructor in the Borrower class. Look at the solution description. It says that there is no constructor or too many constructors. You must check the BOM description.
  4. Double-click the error.
    The Borrower class opens in the BOM editor.

Step 3: Selecting a constructor

You look at the constructors of the Borrower class in the BOM editor. You select the one for tests.

Procedure

  1. In the BOM editor, browse the list of members. You see two constructors.
  2. Double-click the constructor that has five arguments: Borrower(String,String,Date,String,int) constructor. You define it to use it for tests.
  3. In the General Information area, select the Testing and simulation constructor check box.
  4. Save your changes.
  5. Check the project as you did in Step 2. The dialog now reports five errors.
  6. Select the errors in the Testing and Simulation BOM view. They correspond to the arguments in the selected constructor, but they should correspond to an attribute in the BOM.

What to do next

In the next task, you give meaningful names to the arguments of the constructor.