Skip to content

sunil-samuel/BRMS-Decision-Tables-Lessons-Learned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Sunil Samuel
web_github@sunilsamuel.com
http://www.sunilsamuel.com

[Docs] BRMS :: Testing and Debugging for Decision Tables

Overview

Many BRMS (Drools) application uses Excel Decision Table to author rules. Over the years of working with the BRMS engine as a Red Hat Architect, there were several issues that I ran into which seemed as brick walls at the time. But in most cases, these ended up being something very simple. I wanted to capture those issues for future projects.

There are several documentations in existence that shows how to create an application to use an Excel spreadsheet as the BRMS rules, just Google It.

So, I will try to document common issues that you will run into when using spread sheet decision tables on BRMS or Drools.

Technology Stack

Issues

The following are issues that I ran into. If you would like to add to this list, please do so.

Auto Double Quotes Replacements

Both Excel and OpenOffice Spreadsheet replaces the text-based straight double quote (") with the fancy double quote (“ and ”). This causes the BRMS engine to throw the following exceptions

[8,29]: [ERR 101] Line 8:29 no viable alternative at input ''

You would have to disable this features.

Null Checks

Certain rules requires we check for null values. Usually null checks are validation rules and probably should not be in the business rules, but sometimes it may require it. The condition will look as follows:

The key is to use the $1 inside the comments that will tell the BRMS engine the parameter is being used and prevent an exception error.

String Comparison

There are several ways to compare two strings. The best is to use the .equals or .equalsIgnoreCase within the object may be the best.

No Parameters

Certain rules require testing a constant that does not need to come from a param value. In order to do this, we must create a param that is used within the comment section of the rule.

Spreadsheet to DRL

For the purpose of debugging, it may be easier to debug the DRL file that the decision table spreadsheet created. You can convert the Excel spreadsheet to DRL. To do this, update your kmodule.xml file to contain the following configuration parameter:

<property key="drools.dump.dir" value="/tmp/brms/classes" />

While you run your test cases, BRMS will create a corresponding DRL file.

NOTE: The directory must exist, BRMS will not create the directory.

A sample kmodule.xml file is provided below:

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<configuration>
		<property key="drools.propertySpecific" value="ALWAYS" />
		<property key="drools.dump.dir" value="/tmp/brms/classes" />
	</configuration>
	<kbase name="defaultKieBase" default="true" packages="*">
		<ksession name="defaultStatelessKieSession" type="stateless" default="true" />
	</kbase>
</kmodule>

About

BRMS [Drools] :: BRMS Decision Tables Lessons Learned

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published