use of org.drools.compiler.PersonInterface in project drools by kiegroup.
the class NullTest method testNullBehaviour.
@Test
public void testNullBehaviour() throws Exception {
final KieBase kbase = loadKnowledgeBase("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.compiler.PersonInterface in project drools by kiegroup.
the class LiteralTest method testLiteralWithBoolean.
@Test
public void testLiteralWithBoolean() throws Exception {
final KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("literal_with_boolean.drl"));
KieSession session = createKnowledgeSession(kbase);
final List list = new ArrayList();
session.setGlobal("list", list);
final PersonInterface bill = new Person("bill", null, 12);
bill.setAlive(true);
session.insert(bill);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
session.fireAllRules();
assertEquals(bill, ((List) session.getGlobal("list")).get(0));
}
use of org.drools.compiler.PersonInterface in project drools by kiegroup.
the class PatternTest method testBigDecimal.
@Test
public void testBigDecimal() throws Exception {
final KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("big_decimal_and_comparable.drl"));
KieSession session = createKnowledgeSession(kbase);
final List list = new ArrayList();
session.setGlobal("list", list);
final PersonInterface bill = new Person("bill", null, 42);
bill.setBigDecimal(new BigDecimal("42"));
final PersonInterface ben = new Person("ben", null, 43);
ben.setBigDecimal(new BigDecimal("43"));
session.insert(bill);
session.insert(new Cheese("gorgonzola", 43));
session.insert(ben);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
session.fireAllRules();
assertEquals(1, ((List) session.getGlobal("list")).size());
}
use of org.drools.compiler.PersonInterface in project drools by kiegroup.
the class DeleteTest method testAssertRetract.
@Test
public void testAssertRetract() throws Exception {
// postponed while I sort out KnowledgeHelperFixer
final KieBase kbase = loadKnowledgeBase("assert_retract.drl");
final KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal("list", list);
final PersonInterface person = new org.drools.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