Last active
October 6, 2024 10:54
-
-
Save dacr/919291796fb8f970657fcd1dd1c5bb76 to your computer and use it in GitHub Desktop.
Drools forever loop knowledge base / published by https://github.com/dacr/code-examples-manager #f5215bd9-2dff-4529-bdbf-13b5b134b744/deba531fd83185b849837ce727342d79fc2cad0e
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 forever loop knowledge base | |
// keywords : scala, drools, mvel, scalatest, ai, knowledgebase | |
// 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 : f5215bd9-2dff-4529-bdbf-13b5b134b744 | |
// created-on : 2019-10-04T09:15:21+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.*, matchers.*, OptionValues.* | |
object KbTest extends AnyFlatSpec with should.Matchers { | |
val drl = | |
"""package test | |
|declare A end | |
|declare B end | |
|declare B end | |
|rule "init" when not A() then insert(new A()); end | |
|rule "A -> B" when A() then insert(new B()); end | |
|rule "B and A -> not A" when $a:A() B() then delete($a); end | |
|""".stripMargin | |
"test KB" should "work" in { | |
val engine = DroolsEngine(drl) | |
engine.fireAllRules() | |
} | |
} | |
KbTest.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment