Package org.drools.runtime.pipeline

Examples of org.drools.runtime.pipeline.Action


public class ListAdapterTest extends TestCase {
    public void testListAdapter() {
        MockClass mock = new MockClass();
        List list = new ArrayList();
       
        Action action = PipelineFactory.newMvelAction( "this.set = true" );  
       
        ListAdapter listAdapter = new ListAdapterImpl( list, true );       
        action.setReceiver( listAdapter );
       
        assertFalse( mock.isSet() );
        action.receive( mock, new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );

        assertEquals( 1, list.size());
        assertSame( mock, list.get( 0 ) );
        assertTrue( mock.isSet() );
    }
View Full Code Here


public class MvelExpressionTest extends TestCase {
    public void testExpression() {
        MockClass mock = new MockClass();
              
        Callable callable = new CallableImpl();
        Action action = PipelineFactory.newMvelAction( "this.setValues( [0, 1, 2, 3, 4] ) " );
        callable.setReceiver( action );
        Expression expr = PipelineFactory.newMvelExpression( "this.values" );
        action.setReceiver( expr );
        expr.setReceiver( callable );         
       
        assertNull( mock.getValues() );
        List<Integer> list = ( List<Integer> ) callable.call( mock, new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );
View Full Code Here

public class StatefulKnowledgeSessionPipelineTest extends TestCase {
    public void testInsertObject() {
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
       
        StatefulKnowledgeSessionInsertStage insertStage = new StatefulKnowledgeSessionInsertStage();
        insertStage.setReceiver( executeResultHandler );
       
       
View Full Code Here

public class IterateSplitterTest extends TestCase {
    public void testSplitter() {
        MockClass mock = new MockClass();
        List<Integer> list = new ArrayList<Integer>();
       
        Action action = PipelineFactory.newMvelAction( "this.setValues( [0, 1, 2, 3, 4] ) " )
        Expression expr = PipelineFactory.newMvelExpression( "this.values" );
        action.setReceiver( expr );
               
        Splitter splitter = PipelineFactory.newIterateSplitter();
        expr.setReceiver( splitter );
       
        ListAdapter listAdapter = new ListAdapterImpl( list, true );       
        splitter.setReceiver( listAdapter );
       
        assertNull( mock.getValues() );
        action.receive( mock, new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );

       
        System.out.println( list.get( 0 ));
        assertEquals( 5, list.size());
        assertEquals( 0,list.get( 0 ).intValue() );
View Full Code Here

public class CallableTest extends TestCase {
    public void testCallable() {
        MockClass mock = new MockClass();
        Callable callable = new CallableImpl();
        Action action = PipelineFactory.newMvelAction( "this.set = true" );
        callable.setReceiver( action );
        action.setReceiver( callable );
        assertFalse( mock.isSet() );
        callable.call( mock,
                       new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );
        assertTrue( mock.isSet() );
    }
View Full Code Here

public class MvelActionTest extends TestCase {
    public void testAction() {
        MockClass mock = new MockClass();
        List<Integer> list = new ArrayList<Integer>();
       
        Action action = PipelineFactory.newMvelAction( "this.setValues( [0, 1, 2, 3, 4] ) " )

        assertNull( mock.getValues() );
        action.receive( mock, new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );

       
        System.out.println( mock.getValues().get( 0 ));
        assertEquals( 5, mock.getValues().size());
        assertEquals( 0, mock.getValues().get( 0 ).intValue() );
View Full Code Here

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
       
        KnowledgeRuntimeCommand insertStage = PipelineFactory.newStatefulKnowledgeSessionInsert();
        insertStage.setReceiver( executeResultHandler );

        Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );

        Transformer transformer = PipelineFactory.newSmooksFromSourceTransformer( smooks,
                                                                                  "root" );
        transformer.setReceiver( insertStage );

        Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
        pipeline.setReceiver( transformer );

        ResultHandlerImpl resultHandler = new ResultHandlerImpl();
        pipeline.insert( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml" ) ),
                         resultHandler );
       
        FactHandle factHandle = ( FactHandle ) ((Map)resultHandler.getObject()).keySet().iterator().next();
        assertNotNull( factHandle );        

        // now round trip that fact
        Action executeResult = PipelineFactory.newExecuteResultHandler();
       
        Action assignAsResult = PipelineFactory.newAssignObjectAsResult();
        assignAsResult.setReceiver( executeResult );

        transformer = PipelineFactory.newSmooksToSourceTransformer( smooks );
        transformer.setReceiver( assignAsResult );
       
        KnowledgeRuntimeCommand getObject = PipelineFactory.newStatefulKnowledgeSessionGetObject();     
View Full Code Here

        pipeline.insert( new StreamSource( getClass().getResourceAsStream( "SmooksNestedIterable.xml" ) ),
                         resultHandler );

        // now round trip that global

        Action executeResult = PipelineFactory.newExecuteResultHandler();

        Action assignAsResult = PipelineFactory.newAssignObjectAsResult();
        assignAsResult.setReceiver( executeResult );

        transformer = PipelineFactory.newSmooksToSourceTransformer( smooks );
        transformer.setReceiver( assignAsResult );

        pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
View Full Code Here

        StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
        List list = new ArrayList();
        ksession.setGlobal( "list",
                            list );

        Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
       
        Action assignResult = PipelineFactory.newAssignObjectAsResult();
        assignResult.setReceiver( executeResultHandler );

        KnowledgeRuntimeCommand batchExecution = PipelineFactory.newCommandExecutor();
        batchExecution.setReceiver( assignResult );
       
        KnowledgeRuntimeCommand insertStage = PipelineFactory.newInsertObjectCommand();
View Full Code Here

        StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
        List list = new ArrayList();
        ksession.setGlobal( "list",
                            list );

        Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
       
        Action assignResult = PipelineFactory.newAssignObjectAsResult();
        assignResult.setReceiver( executeResultHandler );

        KnowledgeRuntimeCommand batchExecution = PipelineFactory.newCommandExecutor();
        batchExecution.setReceiver( assignResult );
       
        KnowledgeRuntimeCommand insertElementsStage = PipelineFactory.newInsertElementsCommand();
View Full Code Here

TOP

Related Classes of org.drools.runtime.pipeline.Action

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.