use of org.drools.mvel.compiler.InsertedObject in project drools by kiegroup.
the class QueryTest method testQuery2.
@Test
public void testQuery2() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Query.drl");
KieSession session = kbase.newKieSession();
session.fireAllRules();
QueryResults results = getQueryResults(session, "assertedobjquery");
assertEquals(1, results.size());
assertEquals(new InsertedObject("value1"), results.iterator().next().get("assertedobj"));
}
use of org.drools.mvel.compiler.InsertedObject in project drools by kiegroup.
the class QueryTest method testQueryWithParams.
@Test
public void testQueryWithParams() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_QueryWithParams.drl");
KieSession session = kbase.newKieSession();
session.fireAllRules();
String queryName = "assertedobjquery";
String[] arguments = new String[] { "value1" };
QueryResultsImpl resultsImpl = (QueryResultsImpl) session.getQueryResults(queryName, arguments);
QueryResults results = getQueryResults(session, queryName, arguments);
assertEquals(1, results.size());
InsertedObject value = new InsertedObject("value1");
assertEquals(value, results.iterator().next().get("assertedobj"));
results = getQueryResults(session, "assertedobjquery", new String[] { "value3" });
assertEquals(0, results.size());
results = getQueryResults(session, "assertedobjquery2", new String[] { null, "value2" });
assertEquals(1, results.size());
assertEquals(new InsertedObject("value2"), results.iterator().next().get("assertedobj"));
results = getQueryResults(session, "assertedobjquery2", new String[] { "value3", "value2" });
assertEquals(1, results.size());
assertEquals(new InsertedObject("value2"), results.iterator().next().get("assertedobj"));
}
Aggregations