Work
This commit is contained in:
parent
474d3bf5b1
commit
0d40acdd39
6 changed files with 65 additions and 76 deletions
|
|
@ -11,14 +11,16 @@ import droolscours.util.OutputDisplay;
|
|||
//#declare any global variables here
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Le cashFlow est du crédit ou du débit"
|
||||
rule "The cashFlow can be a credit or a debit"
|
||||
|
||||
when
|
||||
$cash :CashFlow(type in ( CashFlow.DEBIT,CashFlow.CREDIT) )
|
||||
|
||||
then
|
||||
showResult.showText("Cash Flow est un crédit ou un débit");
|
||||
showResult.showText("The cashFlow is a credit or a debit");
|
||||
end
|
||||
|
||||
|
||||
rule "Accessor"
|
||||
|
||||
when
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package droolscours;
|
||||
|
||||
import droolscours.util.OutputDisplay;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
|
|
@ -19,11 +20,65 @@ public class Testlesson31 {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
public void testInConstrait() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson3-session");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson31-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
CashFlow cashFlow = new CashFlow();
|
||||
cashFlow.setType(CashFlow.CREDIT);
|
||||
sessionStatefull.insert(cashFlow);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedAccessor() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson31-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Customer customer = new Customer();
|
||||
customer.setName("Héron");
|
||||
customer.setSurname("Nicolas");
|
||||
PrivateAccount pAccount = new PrivateAccount();
|
||||
pAccount.setOwner(customer);
|
||||
sessionStatefull.insert(pAccount);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInOrFact() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson31-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Customer customer = new Customer();
|
||||
|
||||
customer.setCountry("GB");
|
||||
sessionStatefull.insert(customer);
|
||||
PrivateAccount pAccount = new PrivateAccount();
|
||||
pAccount.setOwner(customer);
|
||||
sessionStatefull.insert(pAccount);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotCondition() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson31-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistsCondition() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson31-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account pAccount = new Account();
|
||||
sessionStatefull.insert(pAccount);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue