Search in sources :

Example 61 with QueryResults

use of org.kie.api.runtime.rule.QueryResults in project drools by kiegroup.

the class QueryCepFireUntilHaltTest method noResultTest.

@Test(timeout = 10000L)
public void noResultTest() {
    QueryResults results = ksession.getQueryResults("EventsFromStream");
    assertEquals(0, results.size());
}
Also used : QueryResults(org.kie.api.runtime.rule.QueryResults) Test(org.junit.Test)

Example 62 with QueryResults

use of org.kie.api.runtime.rule.QueryResults in project drools by kiegroup.

the class QueryCepTest method noResultTest.

@Test
public void noResultTest() {
    QueryResults results = ksession.getQueryResults("EventsFromStream");
    assertEquals(0, results.size());
}
Also used : QueryResults(org.kie.api.runtime.rule.QueryResults) Test(org.junit.Test)

Example 63 with QueryResults

use of org.kie.api.runtime.rule.QueryResults in project drools by kiegroup.

the class QueryCepTest method withResultTest.

@Test
public void withResultTest() {
    secondEntryPoint.insert(new TestEvent("minusOne"));
    clock.advanceTime(5, TimeUnit.SECONDS);
    firstEntryPoint.insert(new TestEvent("zero"));
    secondEntryPoint.insert(new TestEvent("one"));
    clock.advanceTime(10, TimeUnit.SECONDS);
    secondEntryPoint.insert(new TestEvent("two"));
    clock.advanceTime(5, TimeUnit.SECONDS);
    secondEntryPoint.insert(new TestEvent("three"));
    QueryResults results = ksession.getQueryResults("ZeroToNineteenSeconds");
    assertEquals(1, results.size());
}
Also used : QueryResults(org.kie.api.runtime.rule.QueryResults) Test(org.junit.Test)

Example 64 with QueryResults

use of org.kie.api.runtime.rule.QueryResults in project drools by kiegroup.

the class QueryCepTest method withNoResultTest.

@Test
public void withNoResultTest() {
    secondEntryPoint.insert(new TestEvent("minusOne"));
    clock.advanceTime(5, TimeUnit.SECONDS);
    firstEntryPoint.insert(new TestEvent("zero"));
    secondEntryPoint.insert(new TestEvent("one"));
    clock.advanceTime(10, TimeUnit.SECONDS);
    secondEntryPoint.insert(new TestEvent("two"));
    // the following expires event "zero" and "one", causing the query to no longer match
    clock.advanceTime(10, TimeUnit.SECONDS);
    secondEntryPoint.insert(new TestEvent("three"));
    QueryResults results = ksession.getQueryResults("ZeroToNineteenSeconds");
    assertEquals(0, results.size());
}
Also used : QueryResults(org.kie.api.runtime.rule.QueryResults) Test(org.junit.Test)

Example 65 with QueryResults

use of org.kie.api.runtime.rule.QueryResults 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());
}
Also used : InsertedObject(org.drools.compiler.InsertedObject) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) QueryResults(org.kie.api.runtime.rule.QueryResults) FlatQueryResults(org.drools.core.runtime.rule.impl.FlatQueryResults) Test(org.junit.Test)

Aggregations

QueryResults (org.kie.api.runtime.rule.QueryResults)79 Test (org.junit.Test)67 KieSession (org.kie.api.runtime.KieSession)58 ArrayList (java.util.ArrayList)30 KieBase (org.kie.api.KieBase)25 List (java.util.List)24 Person (org.drools.modelcompiler.domain.Person)19 QueryResultsRow (org.kie.api.runtime.rule.QueryResultsRow)18 FactHandle (org.kie.api.runtime.rule.FactHandle)15 FlatQueryResults (org.drools.core.runtime.rule.impl.FlatQueryResults)10 Assertions (org.assertj.core.api.Assertions)9 Relationship (org.drools.modelcompiler.domain.Relationship)9 Collection (java.util.Collection)8 Map (java.util.Map)8 TimeUnit (java.util.concurrent.TimeUnit)7 ClockType (org.drools.core.ClockType)7 InternationalAddress (org.drools.modelcompiler.oopathdtables.InternationalAddress)6 KieSessionConfiguration (org.kie.api.runtime.KieSessionConfiguration)6 SessionPseudoClock (org.kie.api.time.SessionPseudoClock)6 Global (org.drools.model.Global)5