Task 4: Testing and debugging a ruleset

You run the ruleset by entering input data in a decision operation configuration, and then test and debug your ruleset.

About this task

You use Rule Designer to test and debug your rule project. You create a run configuration to run the decision operation in Rule Designer. Then, you insert a breakpoint that stops the run at a specific point in the ruleflow, and run the decision operation by using a debug configuration.

Step 1: Creating a run configuration

To test whether the ruleset can run, you run the decision operation in Rule Designer.

Procedure

  1. In the Eclipse menu bar, click Run > Run Configurations.
  2. Right-click Decision Operation and click New.
  3. In the Name field, enter Miniloan Test for the name of the launch configuration.
  4. To set the decision operation, browse to my decision service/my operation, and click OK.
  5. On the Parameters & Arguments tab, click borrower and Edit Value.
  6. In the Edit Parameter Value view, ensure that the Expression value is selected and enter the following text:

    new miniloan.Borrower("Joe", 600, 8000)

  7. Click OK.
  8. Repeat steps 5 to 7 to set loan to the following value:

    new miniloan.Loan(50000, 240, 0.05)

  9. Click Apply, and then click Run.
    In the Console view, you see the results:
    false [Too big Debt-To-Income ratio]
    Tip:

    To open the Console view, on the Window menu, click Show View > Other > General > Console, and then click OK.

Step 2: Inserting a breakpoint

You set a breakpoint in Rule Designer to debug rules.

Procedure

  1. In the Rule Explorer, double-click the miniloan ruleflow to display it in the Ruleflow Editor.
  2. Select and right-click the eligibility task in the ruleflow diagram, and then click Toggle Breakpoint.

    A breakpoint marker is added to the eligibility task.

    Image shows the breakpoint marker in the eligibility node.
  3. In the Rule Explorer, open eligibility and double-click the minimum income rule to open it in the Intellirule editor.
  4. Right-click the fourth line of the rule in the margin, and select Toggle Breakpoint to add a breakpoint to the first action in the rule:
    Image shows the toggle breakpoint.

Step 3: Running the debugger

With the breakpoint in place, you can debug the run.

Procedure

  1. Start the debugger:
    1. Click Debug > Debug Configurations.
    2. Select Decision Operation > Miniloan Test.
    3. Click Debug.
    4. When the Confirm Perspective Switch dialog opens, click Switch to open the Debug perspective.
      The debugging commands are available from the Debug view and from the Run menu.

      Debugging stops at the beginning of the eligibility task, where you inserted the breakpoint.

  2. Step through the rule code:
    1. Click Resume"". Debugging stops at the first action of the minimum income rule at the second breakpoint that you inserted.
    2. In the Variables view, expand the loan object. The value of the approved attribute is true:
      Image shows the expended loan object in the Variables view.
  3. Click Resume "" to complete the run.
    When the run ends, the Console view shows the following message:
    false [Too big Debt-To-Income ratio]
  4. Return to the Rule perspective, and close the ruleflow.

What to do next

In the next task, you deploy a RuleApp from your decision service, and open it in the Rule Execution Server console.