Package org.kie.api.runtime

Examples of org.kie.api.runtime.ExecutionResults


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

        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
        List list = (List) result.getValue( "list" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );
View Full Code Here


        expectedXml += "  <fact-handle identifier=\"outBrie\" external-form=\"" + factHandle.toExternalForm() + "\" /> \n";
        expectedXml += "</execution-results>\n";
        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );

        // brie should not have been added to the list
        List list = (List) result.getValue( "list" );
        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

        setExec( ksession );

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

        outXml = template.requestBody( "direct:exec",
                                       "<batch-execution><query out-identifier='matchingthings' name='results'/></batch-execution>",
View Full Code Here

                                              inXml,
                                              String.class );
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
       
        Thread.currentThread().setContextClassLoader( getClassLoader(ksession) );
        ExecutionResults result = template.requestBody( "direct:unmarshal",
                                                        outXml,
                                                        ExecutionResults.class );
        org.kie.api.definition.type.FactType fT = ksession.getKieBase().getFactType("org.drools.camel.testdomain","Cheese1");
       
        int price = (Integer)fT.get(result.getValue( "outStilton" ), "price");
        assertEquals( 30,
                      price );

        FactHandle factHandle = (FactHandle) result.getFactHandle( "outStilton" );
//        stilton = (Cheese) ksession.getObject( factHandle );
//        assertEquals( 30,
//                      stilton.getPrice() );
       
        String outXml2 = template.requestBody( "direct:execWithLookup",
                                              inXml2,
                                              String.class );
       
       
        Thread.currentThread().setContextClassLoader( getClassLoader(ksession2) );
        ExecutionResults result2 = template.requestBody( "direct:unmarshal",
                                                        outXml2,
                                                        ExecutionResults.class );
       
        org.kie.api.definition.type.FactType fT2 = ksession2.getKieBase().getFactType("org.drools.camel.testdomain","Cheese2");
       
        int price2 = (Integer)fT2.get(result2.getValue( "outStilton" ), "price");
        assertEquals( 35, price2 );
       
//        Cheese2 stilton2 = (Cheese2) result2.getValue( "outStilton" );
//        assertEquals( 35,
//                      stilton2.getPrice() );
//
          factHandle = (FactHandle) result2.getFactHandle( "outStilton" );
//        stilton2 = (Cheese2) ksession2.getObject( factHandle );
//        assertEquals( 35,
//                      stilton2.getPrice() );
       
       
        Thread.currentThread().setContextClassLoader( originalClassLoader );
       
        String expectedXml = "";
        expectedXml += "<execution-results>\n";
        expectedXml += "  <result identifier=\"outStilton\">\n";
        expectedXml += "    <org.drools.camel.testdomain.Cheese1>\n";
        expectedXml += "      <type>stilton</type>\n";
        expectedXml += "      <oldPrice>0</oldPrice>\n";
        expectedXml += "      <price>30</price>\n";
        expectedXml += "    </org.drools.camel.testdomain.Cheese1>\n";
        expectedXml += "  </result>\n";
        expectedXml += "  <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n";
        expectedXml += "</execution-results>\n";
       
        String expectedXml2 = "";
        expectedXml2 += "<execution-results>\n";
        expectedXml2 += "  <result identifier=\"outStilton\">\n";
        expectedXml2 += "    <org.drools.camel.testdomain.Cheese2>\n";
        expectedXml2 += "      <type>stilton</type>\n";
        expectedXml2 += "      <oldPrice>0</oldPrice>\n";
        expectedXml2 += "      <price>35</price>\n";
        expectedXml2 += "    </org.drools.camel.testdomain.Cheese2>\n";
        expectedXml2 += "  </result>\n";
        expectedXml2 += "  <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result2.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n";
        expectedXml2 += "</execution-results>\n";

        assertXMLEqual( expectedXml,
                        outXml );
       
View Full Code Here

        byte[] xmlResp = (byte[]) template.requestBody( "direct:test-with-session",
                                                        xmlReq.toString() );
        assertNotNull( xmlResp );
        System.out.println( new String( xmlResp ) );

        ExecutionResults resp = (ExecutionResults) getJaxbContext().createUnmarshaller().unmarshal( new ByteArrayInputStream( xmlResp ) );
        assertNotNull( resp );

        assertEquals( 2,
                      resp.getIdentifiers().size() );
        assertNotNull( resp.getValue( "lucaz" ) );
        assertNotNull( resp.getValue( "baunax" ) );

        assertNotNull( resp.getFactHandle( "lucaz" ) );
        assertNotNull( resp.getFactHandle( "baunax" ) );
    }
View Full Code Here

            }
            if ( autoFireAllRules ) {
                ksession.fireAllRules();
            }
            if ( command instanceof BatchExecutionCommandImpl ) {
                ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
                return (T) result;
            } else {
                return (T) o;
            }
        } finally {
View Full Code Here

            ((GenericCommand) command).execute( new FixedKnowledgeCommandContext( context,
                                                                                  null,
                                                                                  this.kbase,
                                                                                  this,
                                                                                  results ) );
            ExecutionResults result = session.getExecutionResult();
            return (T) result;
        } finally {
            session.endBatchExecution();
        }
    }
View Full Code Here

            }
            if ( autoFireAllRules ) {
                ksession.fireAllRules( );
            }
            if ( command instanceof BatchExecutionCommandImpl) {
                ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
                return (T) result;
            } else {
                return (T) o;
            }
        } finally {
View Full Code Here

            ((GenericCommand) command).execute( new FixedKnowledgeCommandContext( context,
                                                                                  null,
                                                                                  this.kbase,
                                                                                  this,
                                                                                  results ) );
            ExecutionResults result = session.getExecutionResult();
            return (T) result;
        } finally {
            session.endBatchExecution();
        }
    }
View Full Code Here

        Command insertCmd = CommandFactory.newInsert( stilton, "outStilton" );
        Command fireCmd = CommandFactory.newFireAllRules();
       
        Command cmds = CommandFactory.newBatchExecution( Arrays.asList( new Command[] { insertCmd,fireCmd} ) );
       
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
        stilton = ( Cheese ) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );
       
        Object o = ksession.getObject( (FactHandle) result.getFactHandle( "outStilton" ) );
        assertSame( o, stilton );
    }
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.