This commit is contained in:
Nicolas Héron 2016-05-23 15:52:56 +02:00
commit 543772616c
7 changed files with 80 additions and 11 deletions

View file

@ -51,3 +51,11 @@ rule "Exists"
then
showResult.showText("Account exists");
end
rule "ForAll"
when
forall ( Account( $no : accountno )
CashFlow( accountNo == $no)
)
then
showResult.showText("All cashflows are related to an Account ");
end

View file

@ -81,4 +81,37 @@ public class Testlesson31 {
sessionStatefull.insert(pAccount);
sessionStatefull.fireAllRules();
}
@Test
public void testForALl() throws Exception {
sessionStatefull = KnowledgeSessionHelper
.getStatefulKnowledgeSessionWithCallback(kieContainer, "ksession-lesson3");
OutputDisplay display = new OutputDisplay();
sessionStatefull.setGlobal("showResult", display);
Account a = new Account();
a.setAccountno(1);
a.setBalance(0);
sessionStatefull.insert(a);
CashFlow cash1 = new CashFlow();
cash1.setAccountNo(1);
sessionStatefull.insert(cash1);
CashFlow cash2 = new CashFlow();
cash2.setAccountNo(1);
sessionStatefull.insert(cash2);
Account a2 = new Account();
a2.setAccountno(2);
a2.setBalance(0);
sessionStatefull.insert(a2);
CashFlow cash3 = new CashFlow();
cash3.setAccountNo(2);
sessionStatefull.insert(cash3);
sessionStatefull.fireAllRules();
}
}