Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:24
Show Gist options
  • Select an option

  • Save dacr/6921d569fd33182da358d6a8e383aa0a to your computer and use it in GitHub Desktop.

Select an option

Save dacr/6921d569fd33182da358d6a8e383aa0a to your computer and use it in GitHub Desktop.
Drools Hello world / published by https://github.com/dacr/code-examples-manager #da1c86ab-08d9-4b33-806a-85326acbc9b6/3745c1fc25e8192d3d49cc1b13fa9e4bca0cdc5c
// summary : Drools Hello world
// keywords : scala, drools, mvel, scalatest, ai, helloworld, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : da1c86ab-08d9-4b33-806a-85326acbc9b6
// execution : scala ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc'
// created-on : 2019-09-15T23:03:44+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.5.1"
//> using dep "fr.janalyse::drools-scripting:1.2.0"
//> using dep "org.scalatest::scalatest:3.2.19"
// ---------------------
import fr.janalyse.droolscripting.*, org.scalatest.flatspec.*, org.scalatest.matchers.*
object HelloTest extends AnyFlatSpec with should.Matchers {
"Drools" should "say hello" in {
val drl =
"""package test
|rule "hello" when
|then
| insert("HELLO WORLD");
|end
|""".stripMargin
val engine = DroolsEngine(drl)
engine.fireAllRules()
engine.strings shouldBe List("HELLO WORLD")
}
}
HelloTest.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment