Validation Service may not be the most efficient application to write and debug new rules.  Here is a relatively simple groovy project that attempts to help make this task easier. The aim is to execute rules the same way Validation does.

This utility loads a Validation rules file and an event file, then executes the rules on the event.  Unfortunately this is not a command line utility, currently it can only be executed within an IDE.

Installation and Execution

What you need

Java IDEEclipse Oxygen was used at the time of writing
Groovy IDE pluginGroovy Development Tools 3.3.0

Importing Code

Once the Groovy IDE plugin has been installed, import the following project.

validation-rule-tester.zip

The rules and event files are located in resources.

  • resources/poa-rules.groovy
  • resources/test-event.json

The file names are hard-coded in RuleValidation's main:

class RuleValidation {
	
	static main(args) {
		String rulesFileName = "resources/poa-rules.groovy"
		String eventFileName = "resources/test-event.json"
		
		File rulesFile = new File(rulesFileName)
		RuleManager ruleManager = RulesConfigurationLoader.loadConfiguration(rulesFile.text)
		ruleManager.groovyRules.each{ rule ->
			def attributes = getAttributes(eventFileName, rule.attributePaths)
			displayResults(rule.execute(attributes))
		}
	}
	...

Execution

To execute, right-click on RuleValidation.groovy → Run as... → GroovyScript

Results are displayed as standard out in the console.

Disclaimer

This project is provided as-is.  Enhancements and fixes are encouraged, simply upload a newer version here if the changes are beneficial to others.

  • No labels