Package org.kie.api.runtime

Examples of org.kie.api.runtime.ExecutionResults


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

        String outXml = execContent( "testInsertWithReturnObjectFalse.in.1" );
        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        String expectedXml = getContent( "testInsertWithReturnObjectFalse.expected.1",
                                         ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );

        assertXMLEqual( expectedXml,
                        outXml );
    }
View Full Code Here


        assertXMLEqual( getContent( "testFactHandleReturn.expected.1",
                                    fh.toExternalForm() ),
                        outXml );

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

        List outList = (List) result.getValue( "out-list" );
        assertEquals( 1,
                      outList.size() );
        assertEquals( fh.toExternalForm(),
                      ((FactHandle) outList.get( 0 )).toExternalForm() );
        assertNotSame( fh,
View Full Code Here

        str += "end\n";

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

        ExecutionResults result = execContent( "testGetObject.in.1",
                                               ExecutionResults.class );

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

        String outXml = execContent( "testGetObject.in.2",
                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
        result = unmarshalOutXml( outXml,
                                  ExecutionResults.class );

        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );
    }
View Full Code Here

        str += "end\n";

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

        ExecutionResults result = execContent( "testRetractObject.in.1",
                                               ExecutionResults.class );

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

        String outXml = execContent( "testRetractObject.in.2",
                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );

        outXml = execContent( "testRetractObject.in.3",
                              ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
        result = unmarshalOutXml( outXml,
                                  ExecutionResults.class );

        assertNull( result.getValue( "outStilton" ) );
    }
View Full Code Here

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

        String outXml = execContent( "testModifyObject.in.1" );
        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        String stiltonfh = ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm();

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

        String expectedXml = getContent( "testModifyObject.expected.1",
                                         stiltonfh );

        assertXMLEqual( expectedXml,
                        outXml );

        execContent( "testModifyObject.in.2",
                     ExecutionResults.class,
                     stiltonfh );

        result = execContent( "testModifyObject.in.3",
                              ExecutionResults.class,
                              stiltonfh );

        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 42,
                      stilton.getOldPrice() );
        assertEquals( 55,
                      stilton.getPrice() );

        //now test for code injection:
        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;

        execContent( "testModifyObject.in.4",
                     ExecutionResults.class,
                     stiltonfh );

        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = true;

        // should be the same as before
        result = execContent( "testModifyObject.in.5",
                              ExecutionResults.class,
                              stiltonfh );

        // The value gets turned into a literal to avoid injection
        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( "throwException()",
                      stilton.getType() );

    }
View Full Code Here

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

        assertXMLEqual( getContent( "testInsertElements.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

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

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

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

        List list1 = (List) result.getValue( "list1" );
        assertEquals( 2,
                      list1.size() );
        assertTrue( list1.contains( new Cheese( "stilton",
                                                35 ) ) );
        assertTrue( list1.contains( new Cheese( "stilton",
                                                30 ) ) );

        List myFacts = (List) result.getValue( "myfacts" );
        assertEquals( 2,
                      list1.size() );
        assertTrue( myFacts.contains( new Cheese( "stilton",
                                                  35 ) ) );
        assertTrue( myFacts.contains( new Cheese( "stilton",
                                                  30 ) ) );

        List<FactHandle> factHandles = (List<FactHandle>) result.getFactHandle( "myfacts" );
        List list = new ArrayList();
        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 0 )) ) );
        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 1 )) ) );
        assertTrue( list.contains( new Cheese( "stilton",
                                               35 ) ) );
View Full Code Here

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

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

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

        assertXMLEqual( getContent( "testSetGlobal.expected.1",
                                    ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() ),
                        outXml );

        Cheese stilton = new Cheese( "stilton",
                                     30 );

        assertNull( result.getValue( "list1" ) );

        List list2 = (List) result.getValue( "list2" );
        assertEquals( 1,
                      list2.size() );
        assertEquals( stilton,
                      list2.get( 0 ) );

        List list3 = (List) result.getValue( "outList3" );
        assertEquals( 1,
                      list3.size() );
        assertEquals( stilton,
                      list3.get( 0 ) );
    }
View Full Code Here

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

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

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

        assertXMLEqual( getContent( "testGetGlobal.expected.1",
                                    ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() ),
                        outXml );

        List resultsList = (List) result.getValue( "out-list" );
        assertEquals( 1,
                      resultsList.size() );
        assertEquals( new Cheese( "stilton",
                                  25 ),
                      resultsList.get( 0 ) );
View Full Code Here

        // 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

TOP

Related Classes of org.kie.api.runtime.ExecutionResults

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.