use of org.drools.mvel.compiler.DomainObject in project drools by kiegroup.
the class QueryTest method testQueryWithEval.
@Test
public void testQueryWithEval() throws IOException, ClassNotFoundException {
// [Regression in 5.2.0.M2]: NPE during rule evaluation on MVELPredicateExpression.evaluate(MVELPredicateExpression.java:82)
String str = "package org.drools.mvel.integrationtests\n" + "import " + DomainObject.class.getCanonicalName() + " \n" + "query queryWithEval \n" + " $do: DomainObject()\n" + " not DomainObject( id == $do.id, eval(interval.isAfter($do.getInterval())))\n" + "end";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
DomainObject do1 = new DomainObject();
do1.setId(1);
do1.setInterval(new Interval(10, 5));
DomainObject do2 = new DomainObject();
do2.setId(1);
do2.setInterval(new Interval(20, 5));
ksession.insert(do1);
ksession.insert(do2);
org.kie.api.runtime.rule.QueryResults results = ksession.getQueryResults("queryWithEval");
assertEquals(1, results.size());
assertEquals(do2, results.iterator().next().get("$do"));
ksession.dispose();
}
Aggregations