Debugging using Designer

Print Friendly, PDF & Email

◷ Reading Time: 6 minutes

Introduction

Using FlexRule Designer debugger you can:

  1. Visually track the execution of rules and logic
  2. Navigate to different rules within your RuleSet during debugging
  3. Inspect the values and parameters during debugging
  4. Check the log for your rules execution

You can debug the following rules types using Debugger:

and so on…

In this section we loaded the Car Insurance using DMN project and then we opened a document named Car Premium.xml.

Debugging

To access the debugging capability you can use the Toolboar.

Or “Debug” menu:

  1. Debug: This allows you to debug the currently opened logic and go through it step-by-step by using options on Data Feed Provider
  2. Debug with JSON Composer: Starts debugging with allowing users to visually build a structure as input (No need to configure Data Feed Provider)
  3. Run: This runs the currently opened logic
  4. Stop: This stops the debugging process
  5. Next Step: Goes to the next step of logic
  6. Logic Run Template: Opens the screen to Run/Debug a run template

Debug with JSON Composer

Using this method makes debugging logic straight forward. The JSON Composer screen appears and allows you to enter values for parameters directly.

To debug any logic using JSON Composer:

  1. Select and Open the logic
  2. Press Debug with JSON Composer from Debug menu
  3. The above screen for your logic will be loaded
  4. Press OK to start the debugging

When JSON Composer is used and Fact Concept is defined for parameters, the concept structure of all parameters will be loaded automatically.

Data Feed Provider

Data Feed Provider allows you to connect your data with different methods to the logic for debugging purpose. When your data is ready, you need to provide this to the logic for execution. Using FlexRule Designer, your application does not interact with the logic. Instead, FlexRule Designer allows you to provide data for running and debugging purposes using a screen called Data Feed Provider.

When you have a logic document open and it has the ability to be debugged/run, then you can use the above method to start the debugger.

In the data feed provider screen, there are multiple ways of providing data feed as input to the current logic document:

  1. Compiled Code
  2. Procedural Rule
  3. Data Composer
  4. Excel Sheet

Feeding Data

In this section, we use Data Composer to feed the data in, but if you select other types from the data feeder, the steps are the same. As you select different options on the Data Feed Provider screen, an error message on the bottom left of the screen will guide you if necessary.

Data Composer

Follow the steps in Data Composer to load prepared data into the Data Feed Provider.

Compiled Code

Some engines like Validation and Decision require more information to be executed and debugged rather than only input [parameter]s. These two engines provide more mechanisms with which to interact.

The debugger uses the following method to execute rules:

 /// <summary>
/// Validates a default object as the main reference to complete a decision logic or validation behaviour
/// </summary>
/// <param name="defaultObject"/><param name="logicName"/><param name="inputParameters"/>
/// <returns>
/// true if the default object is validated. Otherwise false
/// </returns>
public bool Validate(object defaultObject, string logicName, params object[] inputParameters) 

As this contract requires more details, on execution you would need to provide additional information via the data feed provider. Therefore, to provide data using the debugger, you need to implement the following interface instead of the simple IRuleFeeder.

 /// <summary>
/// When the logic is a validation, feeding it during a test requires more information. This interface provides that capability.
/// </summary>
public interface IValidationRuleFeeder : IRuleFeeder
{
  /// <summary>
  /// The object that is going to be validated
  /// </summary>
  object CreateTargetValue();
 
  /// <summary>
  /// The logic name to be used on validation
  /// </summary>
  string GetLogicName();
} 

Step-Through

When you are in debug mode, you can step through different parts of the logic and navigate the Yellow Arrow and Highlight by:

  1. Toolbar
  2. F11 key
  3. Debug menu

Run Template

The Run Template allows you to associated prepared data that is created using Data Composer to:

  1. Execution of a logic
  2. A Workflow Task (i.e. Human Task, Receive Task…)

Create and Save a Template

To Create a Run Template,

  • Put the Logic into Debug and set up the Data Feed Provider screen
  • Save Template button will appear

Use the Save and enter details:

This allows you to save the Data Feed Provider’s settings for later reuse.

If you are configuring a Workflow, then you have an option to associate the data to a specific Task (i.e. Human Task, Receive Task, etc.) By saving this Template, the Data Feed Provider Configuration will be reusable in the future for running or debugging the logic document.

Logic run template

On FlexRule Designer Toolbar, there is an icon called: Logic Run template:

By clicking on the “Logic Run Template”, a new page will appear in which you can choose your created Template. Also, as highlighted in the screenshot below, we can filter all Templates which are related to a current Document:

Updated on July 22, 2019

Was this article helpful?

Related Articles