Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 25, 2024 10:19
Show Gist options
  • Save dacr/6921d569fd33182da358d6a8e383aa0a to your computer and use it in GitHub Desktop.
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/ba360dc27a0c8d4560cebefdfdebd18c2b2864aa
// summary : Drools Hello world
// keywords : scala, drools, mvel, scalatest, ai, helloworld, @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 : 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.4.2"
//> using dep "fr.janalyse::drools-scripting:1.1.0"
//> using dep "org.scalatest::scalatest:3.2.16"
// ---------------------
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