0

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.

Tim
  • 1
  • 1
  • What about [writing a test](https://stackoverflow.com/questions/1206443/how-do-you-unit-test-jboss-rules-drools-rules)? – Mike Jun 11 '23 at 16:13
  • All of those listed errors are accurate, though you'd have to understand that the eval messages are indicating there's a problem _near_ the eval and not with the eval itself. What more did you want? – Roddy of the Frozen Peas Jun 12 '23 at 17:35

0 Answers0