use of org.drools.mvel.compiler.PersonInterface in project drools by kiegroup.
the class ExecutionFlowControlTest method testSalienceIntegerAndLoadOrder.
@Test(timeout = 10000)
public void testSalienceIntegerAndLoadOrder() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_salienceIntegerRule.drl");
KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal("list", list);
final PersonInterface person = new Person("Edson", "cheese");
ksession.insert(person);
ksession.fireAllRules();
assertEquals("Three rules should have been fired", 3, list.size());
assertEquals("Rule 4 should have been fired first", "Rule 4", list.get(0));
assertEquals("Rule 2 should have been fired second", "Rule 2", list.get(1));
assertEquals("Rule 3 should have been fired third", "Rule 3", list.get(2));
}
use of org.drools.mvel.compiler.PersonInterface in project drools by kiegroup.
the class NullTest method testNullBehaviour.
@Test
public void testNullBehaviour() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "null_behaviour.drl");
KieSession session = kbase.newKieSession();
final PersonInterface p1 = new Person("michael", "food", 40);
final PersonInterface p2 = new Person(null, "drink", 30);
session.insert(p1);
session.insert(p2);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
session.fireAllRules();
}
use of org.drools.mvel.compiler.PersonInterface in project drools by kiegroup.
the class NullTest method testNullConstraint.
@Test
public void testNullConstraint() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "null_constraint.drl");
KieSession session = kbase.newKieSession();
final List foo = new ArrayList();
session.setGlobal("messages", foo);
final PersonInterface p1 = new Person(null, "food", 40);
final Primitives p2 = new Primitives();
p2.setArrayAttribute(null);
session.insert(p1);
session.insert(p2);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
session.fireAllRules();
assertEquals(2, ((List) session.getGlobal("messages")).size());
}
use of org.drools.mvel.compiler.PersonInterface in project drools by kiegroup.
the class DeleteTest method testAssertRetract.
@Test
public void testAssertRetract() throws Exception {
// postponed while I sort out KnowledgeHelperFixer
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "assert_retract.drl");
final KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal("list", list);
final PersonInterface person = new org.drools.mvel.compiler.Person("michael", "cheese");
person.setStatus("start");
ksession.insert(person);
ksession.fireAllRules();
final List<String> results = (List<String>) ksession.getGlobal("list");
for (final String result : results) {
logger.info(result);
}
assertEquals(5, results.size());
assertTrue(results.contains("first"));
assertTrue(results.contains("second"));
assertTrue(results.contains("third"));
assertTrue(results.contains("fourth"));
assertTrue(results.contains("fifth"));
}
Aggregations