Last active
October 6, 2024 10:54
-
-
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/7a29854484b97a03e2048a859cf9d7fbaa0b8775
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.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