Package org.kie.api.runtime.rule

Examples of org.kie.api.runtime.rule.QueryResults


        List<String> list = new ArrayList<String>();
        ksession.setGlobal( "list",
                            list );

        QueryResults results = null;

        Person p = new Person();
        p.setLikes( "lamp" );
        FactHandle handle = ksession.insert( p );
        ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true);
View Full Code Here


        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
        ksession.fireAllRules();

        QueryResults res = ksession.getQueryResults( "getResults", "1", Variable.v );
        assertEquals( 1, res.size() );

        Object o = res.iterator().next().get( "$holders" );
        assertTrue( o instanceof List );
        assertEquals( 1, ((List) o).size() );
    }
View Full Code Here

        StatefulKnowledgeSession ks = getSessionFromString( source );
        TraitFactory.setMode( mode, ks.getKieBase() );

        ks.fireAllRules();

        QueryResults res = ks.getQueryResults( "QueryTraitA" );

        assertEquals( 1, res.size() );

    }
View Full Code Here

        List list = new ArrayList();
        ks.setGlobal( "list", list );
        ks.fireAllRules();

        QueryResults res;
        res = ks.getQueryResults( "queryA1" );
        assertEquals( 1, res.size() );
    }
View Full Code Here

        List list = new ArrayList();
        ks.setGlobal( "list", list );
        ks.fireAllRules();

        QueryResults res = ks.getQueryResults( "queryA" );
        Iterator<QueryResultsRow> iter = res.iterator();
        Object a = iter.next().get( "$x" );
        assertFalse( iter.hasNext() );

        assertEquals( 1, res.size() );

    }
View Full Code Here

        Query q2 = session.getKieBase().getQuery( "org.drools.tms.test", "bar" );

        assertNotNull( q1 );
        assertNotNull( q2 );

        QueryResults q10res = session.getQueryResults( "foo", "foo" );
        QueryResults q11res = session.getQueryResults( "foo", "foo", Variable.v );
        QueryResults q20res = session.getQueryResults( "bar", "foo", Variable.v );

        assertEquals( 1, q10res.size() );
        assertEquals( 1, q11res.size() );
        assertEquals( 1, q20res.size() );

        QueryResultsRow row10 = q10res.iterator().next();
        QueryResultsRow row11 = q11res.iterator().next();
        QueryResultsRow row20 = q20res.iterator().next();

        assertEquals( "foo", row10.get( "$s" ) );
        assertEquals( "foo", row11.get( "$s" ) );
        assertEquals( "foo", row20.get( "$s" ) );
View Full Code Here

        final KieSession session = kbase.newStatefulKnowledgeSession();

        session.insert( new Cheese( "stilton",
                                    15 ) );

        QueryResults results = session.getQueryResults( "query1",
                                                        "stilton" );
        assertEquals( 1,
                      results.size() );

        Object object = results.iterator().next().get("stilton");
        assertEquals( new Cheese( "stilton",
                                  15 ),
                      object );

        results = session.getQueryResults( "query1",
                                           new Object[]{"cheddar"} );
        assertEquals( 0,
                      results.size() );

        session.insert(new Cheese("dolcelatte",
                                  20));
        results = session.getQueryResults( "query2",
                                           new Object[]{} );
        assertEquals( 2,
                      results.size() );
    }
View Full Code Here

        StatefulKnowledgeSession ks = getSessionFromString( source );

        ks.fireAllRules();

        QueryResults res = ks.getQueryResults( "QueryTraitA" );

        assertEquals( 1, res.size() );

    }
View Full Code Here

        List list = new ArrayList();
        ks.setGlobal( "list", list );
        ks.fireAllRules();

        QueryResults res = ks.getQueryResults( "queryA1" );
        assertEquals( 1, res.size() );

    }
View Full Code Here

        List list = new ArrayList();
        ks.setGlobal( "list", list );
        ks.fireAllRules();

        QueryResults res = ks.getQueryResults( "queryA" );
        Iterator<QueryResultsRow> iter = res.iterator();
        Object a = iter.next().get( "$x" );
        assertFalse( iter.hasNext() );

        assertEquals( 1, res.size() );

    }
View Full Code Here

TOP

Related Classes of org.kie.api.runtime.rule.QueryResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.