Examples of ExecutionResults


Examples of org.drools.runtime.ExecutionResults

        // Can't compare content a hashmap of objects keeps changing order
        // assertXMLEqual( getContent( "testGetObjects.expected.1" ),
        //                outXml );

        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        List list = (List) result.getValue( "list1" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        // Order is not determinstic, so can't test.
        //         assertXMLEqual( getContent( "testQuery.expected.1" ),
        //                        outXml );
        getContent( "testQuery.expected.1" ); // just to force a tostring for comparison

        ExecutionResults batchResult = unmarshalOutXml( outXml,
                                                        ExecutionResults.class );

        Cheese stilton1 = new Cheese( "stilton",
                                      1 );
        Cheese cheddar1 = new Cheese( "cheddar",
                                      1 );
        Cheese stilton2 = new Cheese( "stilton",
                                      2 );
        Cheese cheddar2 = new Cheese( "cheddar",
                                      2 );

        Set set = new HashSet();
        List list = new ArrayList();
        list.add( stilton1 );
        list.add( cheddar1 );
        set.add( list );

        list = new ArrayList();
        list.add( stilton2 );
        list.add( cheddar2 );
        set.add( list );

        org.drools.runtime.rule.QueryResults results = (org.drools.runtime.rule.QueryResults) batchResult.getValue( "cheeses" );
        assertEquals( 2,
                      results.size() );
        assertEquals( 2,
                      results.getIdentifiers().length );
        Set newSet = new HashSet();
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = execContent( "testManualFireAllRules.in.1" );

        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        assertXMLEqual( getContent( "testManualFireAllRules.expected.1",
                                    ((FactHandle) result.getFactHandle( "outBrie" )).toExternalForm() ),
                        outXml );

        // brie should not have been added to the list
        List list = (List) result.getValue( "list1" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );

        Set expectedList = new HashSet();
        expectedList.add( stilton25 );
        expectedList.add( stilton30 );

        assertEquals( expectedList,
                      new HashSet( list ) );

        // brie should not have changed
        Cheese brie10 = new Cheese( "brie",
                                    10 );
        brie10.setOldPrice( 5 );
        assertEquals( brie10,
                      result.getValue( "outBrie" ) );
    }
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        String outXml = execContent( "testProcess.in.1" );

        assertXMLEqual( getContent( "testProcess.expected.1" ),
                        outXml );

        ExecutionResults results = unmarshalOutXml( outXml,
                                                    ExecutionResults.class );

        list = (List) results.getValue( "out-list" );

        assertEquals( 1,
                      list.size() );
        assertEquals( "John Doe",
                      list.get( 0 ) );
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        str += "end\n";

        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        ExecutionResults results = null;
        String outXml = null;
        ClassLoader orig = null;
        ClassLoader cl = ((InternalRuleBase) ((StatefulKnowledgeSessionImpl) ksession).getRuleBase()).getRootClassLoader();
        try {
            orig = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader( cl );
            outXml = execContent( "testInsertObjectWithDeclaredFact.in.1" );
            results = unmarshalOutXml( outXml,
                                       ExecutionResults.class );
        } finally {
            Thread.currentThread().setContextClassLoader( orig );
        }
        FactHandle factHandle = (FactHandle) results.getFactHandle( "outStilton" );
        Object object = results.getValue( "outStilton" );

        assertEquals( "org.foo.Whee",
                      object.getClass().getName() );
        assertXMLEqual( getContent( "testInsertObjectWithDeclaredFact.expected.1",
                                    factHandle.toExternalForm() ),
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

            orig = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader( cl );

            String outXml = execContent( "testInsertObjectWithDeclaredFactAndQuery.in.1" );

            ExecutionResults results = unmarshalOutXml( outXml,
                                                        ExecutionResults.class );
            FactHandle fh = (FactHandle) results.getFactHandle( "outStilton" );

            outXml = execContent( "testInsertObjectWithDeclaredFactAndQuery.in.2" );

            assertXMLEqual( getContent( "testInsertObjectWithDeclaredFactAndQuery.expected.1",
                                        fh.toExternalForm() ),
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = execContent( "testExecutionNodeLookup.in.1" );
        ExecutionResults results = unmarshalOutXml( outXml,
                                                    ExecutionResults.class );

        Cheese stilton = (Cheese) results.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        FactHandle factHandle = (FactHandle) results.getFactHandle( "outStilton" );
        stilton = (Cheese) ksession.getObject( factHandle );
        assertEquals( 30,
                      stilton.getPrice() );

        assertXMLEqual( getContent( "testExecutionNodeLookup.expected.1",
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        commands.add(CommandFactory.newInsert(p, "tempPerson"));
        BatchExecutionCommand command = CommandFactory.newBatchExecution(commands);
        String xmlCommand = template.requestBody("direct:marshall", command, String.class);

        String xml = template.requestBody("direct:test-session", xmlCommand, String.class);
        ExecutionResults res = (ExecutionResults) template.requestBody("direct:unmarshall", xml);

        Object o = res.getFactHandle("tempPerson");
        assertTrue("returned String instead of FactHandle instance", o instanceof FactHandle);      
    }
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

    private QueryResults query(String queryName, Object[] args) {
        Command command = CommandFactory.newQuery("persons", queryName, args);
        String queryStr = template.requestBody("direct:marshall", command, String.class);

        String json = template.requestBody("direct:test-session", queryStr, String.class);
        ExecutionResults res = (ExecutionResults) template.requestBody("direct:unmarshall", json);
        return (QueryResults) res.getValue("persons");
    }
View Full Code Here

Examples of org.drools.runtime.ExecutionResults

        expectedXml += "</execution-results>\n";

        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = template.requestBody( "direct:unmarshal",
                                                        outXml,
                                                        ExecutionResults.class );

        List list = (List) result.getValue( "list" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.