use of org.drools.mvel.compiler.Person in project drools by kiegroup.
the class AlphaNodeTest method testAlphaModifyDelete.
@Test
public void testAlphaModifyDelete() {
String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + " $p : Person(name == \"Mario\")\n" + "then\n" + " modify($p) { setName(\"Mark\")}" + "end\n" + "rule R2 when\n" + " $p : Person(name == \"Mark\")\n" + "then\n" + " delete($p);" + "end\n" + "rule R3 when\n" + " not( Person() )\n" + "then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Person("Mario"));
assertEquals(3, ksession.fireAllRules());
}
use of org.drools.mvel.compiler.Person in project drools by kiegroup.
the class AlphaNodeTest method testSharedAlpha.
@Test
public void testSharedAlpha() {
String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + " $p : Person(name == \"Mario\")\n" + "then\n" + "end\n" + "rule R2 when\n" + " $p : Person(name == \"Mario\")\n" + "then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Person("Mario"));
assertEquals(2, ksession.fireAllRules());
}
use of org.drools.mvel.compiler.Person in project drools by kiegroup.
the class AlphaNodeTest method test3Alpha.
@Test
public void test3Alpha() {
String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + " $p : Person(name == \"Mario\")\n" + "then\n" + " modify($p) { setAge(2) }" + " modify($p) { setAge(2) }" + "end\n" + "rule R3 when\n" + " $p : Person(age > 1)\n" + "then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Person("Mario", 0));
assertEquals(2, ksession.fireAllRules());
}
use of org.drools.mvel.compiler.Person in project drools by kiegroup.
the class AlphaNodeTest method testBetaModifyWithAlpha.
@Test
public void testBetaModifyWithAlpha() {
String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + " $p : Person(name == \"Mario\")\n" + " $s : String(this == $p.name)\n" + "then\n" + " modify($p) { setName(\"Mark\") }" + "end\n" + "rule R2 when\n" + " $p : Person(name == \"Mark\")\n" + "then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Person("Mario"));
ksession.insert("Mario");
assertEquals(2, ksession.fireAllRules());
}
use of org.drools.mvel.compiler.Person in project drools by kiegroup.
the class AlphaNodeTest method testAlphaModifyWithBeta.
@Test
public void testAlphaModifyWithBeta() {
String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + " $p : Person(name == \"Mario\")\n" + "then\n" + " modify($p) { setName(\"Mark\") }" + "end\n" + "rule R2 when\n" + " $p : Person(name == \"Mark\")\n" + " $s : String(this == $p.name)\n" + "then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Person("Mario"));
ksession.insert("Mark");
assertEquals(2, ksession.fireAllRules());
}
Aggregations