use of org.drools.compiler.Address in project drools by kiegroup.
the class FieldAccessTest method testGenericsOption.
@Test
public void testGenericsOption() throws Exception {
// JBRULES-3579
final String str = "import org.drools.compiler.*;\n" + "rule R1 when\n" + " $c : Cheese( $type: type )\n" + " $p : Person( $name : name, addressOption.get.street == $type )\n" + "then\n" + "end\n";
final KieBase kbase = loadKnowledgeBaseFromString(str);
final KieSession ksession = kbase.newKieSession();
final Person p = new Person("x");
p.setAddress(new Address("x", "x", "x"));
ksession.insert(p);
ksession.insert(new Cheese("x"));
assertEquals(1, ksession.fireAllRules());
ksession.dispose();
}
use of org.drools.compiler.Address in project drools by kiegroup.
the class UpdateTest method testModifyBlockWithFrom.
@Test
public void testModifyBlockWithFrom() throws Exception {
final KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("test_ModifyBlockWithFrom.drl"));
final KieSession ksession = createKnowledgeSession(kbase);
final List results = new ArrayList();
ksession.setGlobal("results", results);
final Person bob = new Person("Bob");
final Address addr = new Address("abc");
bob.addAddress(addr);
ksession.insert(bob);
ksession.insert(addr);
ksession.fireAllRules();
// modify worked
assertEquals("12345", addr.getZipCode());
// chaining worked
assertEquals(1, results.size());
assertEquals(addr, results.get(0));
}
Aggregations