Last active
May 25, 2024 10:19
-
-
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/c8fd17af319a475ef4161e098f36a96ed1eeaaf2
This file contains 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.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._, 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