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 of this utility is to load execute rules the same way Validation does.
This utility loads a Validation rules file and an event file, then execute executes the rules on the event. Unfortunately , this is not a command line utility, currently it currently can only be executed within an IDE.
Installation and Execution
What you need
Java IDE |
...
Eclipse |
...
Oxygen was used at the time of writing |
Groovy |
...
IDE plugin | Groovy Development Tools 3.3.0 |
Importing Code
Once the Groovy IDE plugin has been installed, import the following project.
View file | ||||
---|---|---|---|---|
|
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.MainRight-click on RuleValidation → Run as... → 's main:
Code Block | ||
---|---|---|
| ||
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.