Package org.kie.api.runtime

Examples of org.kie.api.runtime.ExecutionResults


       
        StatelessKnowledgeSession ksession = getSession2( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        GenericCommand cmd = ( GenericCommand ) CommandFactory.newInsert( stilton, "outStilton" );
        BatchExecutionCommandImpl batch = new BatchExecutionCommandImplArrays.asList( new GenericCommand<?>[] { cmd } ) );
       
        ExecutionResults result = ( ExecutionResults ) ksession.execute( batch );
        stilton = ( Cheese ) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );
    }
View Full Code Here


        cmds.add( setGlobal1 );
        cmds.add( setGlobal2 );
        cmds.add( setGlobal3 );
        cmds.addinsert );
       
        ExecutionResults result = ( ExecutionResults ) ksession.execute( CommandFactory.newBatchExecution( cmds ) );
       
        assertEquals( 30,
                      stilton.getPrice() );
       
        assertNull( result.getValue( "list1" ) );
       
        list2 = ( List ) result.getValue( "list2" );
        assertEquals( 1, list2.size() );
        assertSame( stilton, list2.get( 0 ) );
       
         
       
        list3 = ( List ) result.getValue( "outList3" );
        assertEquals( 1, list3.size() );
        assertSame( stilton, list3.get( 0 ) );
    }
View Full Code Here

        cmds.add( CommandFactory.newInsert( cheddar2 ) );
        cmds.add( CommandFactory.newInsert( cheddar3 ) );
       
        cmds.addCommandFactory.newQuery( "cheeses", "cheeses" ) );
       
        ExecutionResults batchResult = (ExecutionResults) ksession.execute( CommandFactory.newBatchExecution( cmds ) );
       
        org.kie.api.runtime.rule.QueryResults results = ( org.kie.api.runtime.rule.QueryResults) batchResult.getValue( "cheeses" );
        assertEquals( 3, results.size() );
        assertEquals( 2, results.getIdentifiers().length );
        Set newSet = new HashSet();
        for ( org.kie.api.runtime.rule.QueryResultsRow result : results ) {
            list = new ArrayList();
View Full Code Here

        List<Command<?>> commands = new ArrayList<Command<?>>();
        commands.add(new NewKnowledgeBuilderCommand("kbuilder"));
        commands.add(new KnowledgeBuilderAddCommand(res, ResourceType.DRL, null));
        Command<?> cmds = CommandFactory.newBatchExecution( commands );
   
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );

        assertNotNull(result);
        Object kbuilder = result.getValue("kbuilder");
        assertNotNull(kbuilder);
        assertTrue(kbuilder instanceof KnowledgeBuilder);
        assertTrue(((KnowledgeBuilder) kbuilder).hasErrors());
    }
View Full Code Here

        commands.add(new NewKnowledgeBuilderCommand());
        commands.add(new KnowledgeBuilderAddCommand(res, ResourceType.DRL, null));
        commands.add(new KnowledgeBuilderHasErrorsCommand("hasErrors"));
        Command<?> cmds = CommandFactory.newBatchExecution( commands );
   
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
       
        assertNotNull(result);
        Object hasErrors = result.getValue("hasErrors");
        assertNotNull(hasErrors);
        assertEquals(Boolean.TRUE, hasErrors);
    }
View Full Code Here

        commands.add(new NewKnowledgeBuilderCommand());
        commands.add(new KnowledgeBuilderAddCommand(res, ResourceType.DRL, null));
        commands.add(new KnowledgeBuilderGetErrorsCommand("errors"));
        Command<?> cmds = CommandFactory.newBatchExecution( commands );
   
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
       
        assertNotNull(result);
        Object errors = result.getValue("errors");
        assertNotNull(errors);
        assertTrue(errors instanceof KnowledgeBuilderErrors);
        KnowledgeBuilderErrors kbErrors = (KnowledgeBuilderErrors) errors;

        assertEquals( 2, kbErrors.size());
View Full Code Here

        commands.add(new NewKnowledgeBuilderCommand());
        commands.add(new KnowledgeBuilderAddCommand( ResourceFactory.newByteArrayResource(ruleString.getBytes()), ResourceType.DRL, null));
        commands.add(new KnowledgeBuilderGetKnowledgePackagesCommand("pkgs"));
        Command<?> cmds = CommandFactory.newBatchExecution( commands );
   
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
        assertNotNull(result);
        Object pkgsObject = result.getValue("pkgs");
        assertTrue(pkgsObject != null && pkgsObject instanceof Collection<?>);
        kbase.addKnowledgePackages( ((Collection<KnowledgePackage>) pkgsObject) );

        ksession.dispose();
        ksession = createKnowledgeSession(kbase);
View Full Code Here

        List<Command<?>> commands = new ArrayList<Command<?>>();
        commands.add(CommandFactory.newInsert(expected_1, "out_1"));
        commands.add(CommandFactory.newInsert(expected_2, "out_2"));
        Command cmds = CommandFactory.newBatchExecution( commands );
       
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
       
        Object fact_1 = result.getValue("out_1");
        assertNotNull(fact_1);
        Object fact_2 = result.getValue("out_2");
        assertNotNull(fact_2);
        ksession.fireAllRules();

        Object [] expectedArr = {expected_1, expected_2};
        List<Object> expectedList = new ArrayList<Object>(Arrays.asList(expectedArr));
View Full Code Here

       
        List<Command<?>> commands = new ArrayList<Command<?>>();
        commands.add(CommandFactory.newInsertElements(factCollection, "out_list", true, null));
        Command cmds = CommandFactory.newBatchExecution( commands );
       
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
       
        Collection<? extends Object> outList = (Collection<? extends Object>) result.getValue("out_list");
        assertNotNull(outList);
        ksession.fireAllRules();
   
        List<Object> expectedList = new ArrayList<Object>(Arrays.asList(expectedArr));
       
View Full Code Here

        List<Command<?>> commands = new ArrayList<Command<?>>();
        commands.add(CommandFactory.newSetGlobal( "globalCheeseCountry", "France", true ));
   
        Command cmds = CommandFactory.newBatchExecution( commands );
   
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
        assertNotNull(result);
        Object global = result.getValue("globalCheeseCountry");
        assertNotNull(global);
        assertEquals("France", global);
    }
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.