use of org.drools.compiler.InsertedObject in project drools by kiegroup.
the class QueryTest method testQueryWithParams.
@Test
public void testQueryWithParams() throws Exception {
KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("test_QueryWithParams.drl"));
KieSession session = createKieSession(kbase);
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, ((InternalFactHandle) results.iterator().next().getFactHandle("assertedobj")).getObject());
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"), ((InternalFactHandle) results.iterator().next().getFactHandle("assertedobj")).getObject());
results = getQueryResults(session, "assertedobjquery2", new String[] { "value3", "value2" });
assertEquals(1, results.size());
assertEquals(new InsertedObject("value2"), ((InternalFactHandle) results.iterator().next().getFactHandle("assertedobj")).getObject());
}
use of org.drools.compiler.InsertedObject in project drools by kiegroup.
the class QueryTest method testQuery2.
@Test
public void testQuery2() throws Exception {
KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("test_Query.drl"));
KieSession session = createKieSession(kbase);
session.fireAllRules();
QueryResults results = getQueryResults(session, "assertedobjquery");
assertEquals(1, results.size());
assertEquals(new InsertedObject("value1"), ((InternalFactHandle) results.iterator().next().getFactHandle("assertedobj")).getObject());
}
Aggregations