Drools - How to validate dynamically generated Drools rules from an ftl template file; before firing them?

81 views Asked by At

want to validate the rules and send them to other part of monolith application so, that it is ready to fire all rules as i'm generating dynamic drools rules using a template(ftl) file. So, is there any best way to validate the rules before firing them?

These are the rules which i want to validate:
rule "Check Trade Amount"
salience 99
enabled true
dialect "mvel"
when
    $map : Map()
    eval(String.valueOf($map.get("product.type"))==("Physical Goods"))
        AND
    eval(Integer.parseInt($map.get("payment.amount"))>200000)
        OR
    eval(String.valueOf($map.get("product.type"))==("Bank Transfer"))
        AND
    eval(Integer.parseInt($map.get("payment.amount"))>30000)
then
    System.out.println("Decision: escalate");
    $map.put("decision", "Escalate");
end

rule "Check White List"
salience 98
enabled true
dialect "mvel"
when
    $map : Map()
    (transaction.payee memberOf ["Mark", "bill gates", "Good guy"])
then
    System.out.println("Decision: escalate");
    $map.put("decision", "Escalate");
end

I tried the drools-verifier to validate these rules, but getting these errors: Rule verification failed with errors: Error: [ERR 102] Line 26:8 mismatched input 'eval' in rule "Check Trade Amount" in pattern

Error: [ERR 102] Line 28:8 mismatched input 'eval' in rule "Check Trade Amount" in pattern

Error: [ERR 102] Line 30:8 mismatched input 'eval' in rule "Check Trade Amount" in pattern

Error: [ERR 102] Line 42:27 mismatched input 'memberOf' in rule "Check White List"

Error: Parser returned a null Package

Error: Verifier could not form a PackageDescr from the resources that it was trying to verify.

0

There are 0 answers