Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/3733f31509bd265eb103b62be5b3b8b7 to your computer and use it in GitHub Desktop.
Save dacr/3733f31509bd265eb103b62be5b3b8b7 to your computer and use it in GitHub Desktop.
Drools parsing issues / published by https://github.com/dacr/code-examples-manager #35be246f-26fd-4583-8da7-286d601cf37b/a2c00a4526361a020c05ef16dd09cc5cf75e9249
// summary : Drools parsing issues
// keywords : scala, drools, mvel, scalatest, ai, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 35be246f-26fd-4583-8da7-286d601cf37b
// created-on : 2019-10-02T17:04:57+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.1.1"
//> using dep "fr.janalyse::drools-scripting:1.0.16"
//> using dep "org.scalatest::scalatest:3.2.10"
// ---------------------
import fr.janalyse.droolscripting._, org.scalatest._, flatspec._, matchers._, OptionValues._
object DroolsParsingTest extends AnyFlatSpec with should.Matchers {
info("Be aware of the fact that drools knowledge base parsing may just fail...")
"Drools parser" should "(not) give NullPointerException on inheritance issue" in {
val drl =
"""package test
|declare Truc end
|declare Muche extends truc end
|""".stripMargin
intercept[NullPointerException] { // still true with drools 7.54.0.FINAL
val engine = DroolsEngine(drl) // because Muche extends truc instead of Truc
engine.fireAllRules()
}
}
}
DroolsParsingTest.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment