Package org.drools.core.reteoo

Examples of org.drools.core.reteoo.LeftTupleImpl


                                 Person person) {
            wm = ((StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession());

            this.context = context;
            final InternalFactHandle f0 = (InternalFactHandle) wm.insert( person );
            tuple = new LeftTupleImpl( f0,
                                   null,
                                   true );
            this.salience = salience;
            this.halt = false;
            this.error = false;
View Full Code Here


        final Cheese cheddar2 = new Cheese( "cheddar",
                                            8 );
        final InternalFactHandle f0 = (InternalFactHandle) ksession.insert( new InitialFactImpl() );
        final InternalFactHandle f1 = (InternalFactHandle) ksession.insert( cheddar1 );
        final InternalFactHandle f2 = (InternalFactHandle) ksession.insert( cheddar2 );
        final LeftTupleImpl tuple = new LeftTupleImpl( f0,
                                               sink,
                                               true );

        Object wmContext = acc.createWorkingMemoryContext();
        Object accContext = acc.createContext();
View Full Code Here

        final HashMap map = new HashMap();
        workingMemory.setGlobal( "map",
                                 map );

        final LeftTupleImpl tuple = new MockTuple( new HashMap() );
        tuple.setLeftTupleSink( new RuleTerminalNode(1, new CompositeObjectSinkAdapterTest.MockBetaNode(), rule,rule.getLhs(), 0,new BuildContext(kBase, null) )  );
        final Activation activation = new MockActivation( rule,
                                                          0,
                                                          rule.getLhs(),
                                                          tuple );
View Full Code Here

        final HashMap map = new HashMap();

        workingMemory.setGlobal( "map",
                                 map );

        final LeftTupleImpl tuple = new MockTuple( new HashMap() );
        tuple.setLeftTupleSink( new RuleTerminalNode(1, new CompositeObjectSinkAdapterTest.MockBetaNode(), newRule,newRule.getLhs(), 0, new BuildContext(kBase, null) )  );
        final Activation activation = new MockActivation( newRule,
                                                          0,
                                                          newRule.getLhs(),
                                                          tuple );
View Full Code Here

            Mockito.when( mockedSink.createLeftTuple( (InternalFactHandle) anyObject(), (LeftTupleSink) anyObject(), anyBoolean() ) ).thenAnswer( new Answer() {

                public Object answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();                  
                    return new LeftTupleImpl((InternalFactHandle)args[0], (LeftTupleSink)args[1], ((Boolean)args[2]).booleanValue()  );
                }
            });
                       
           
            Mockito.when( mockedSink.createLeftTuple( (LeftTuple) anyObject(), (LeftTupleSink) anyObject()(PropagationContext) anyObject(), anyBoolean()) ).thenAnswer( new Answer() {

                public Object answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();                  
                    return new LeftTupleImpl((LeftTuple)args[0], (LeftTupleSink)args[1], (PropagationContext) args[2] , ((Boolean)args[3]).booleanValue()  );
                }
            });     
           
            Mockito.when( mockedSink.createLeftTuple( (LeftTuple) anyObject(), (RightTuple) anyObject(), (LeftTupleSink) anyObject()) ).thenAnswer( new Answer() {
                public Object answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();                  
                    return new LeftTupleImpl((LeftTuple)args[0], (RightTuple)args[1], (LeftTupleSink) args[2] );
                }
            });             
           
            Mockito.when( mockedSink.createLeftTuple( (LeftTuple) anyObject(), (RightTuple) anyObject()(LeftTuple) anyObject(), (LeftTuple) anyObject(), (LeftTupleSink) anyObject(), anyBoolean()) ).thenAnswer( new Answer() {
                public Object answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();                  
                    return new LeftTupleImpl((LeftTuple)args[0], (RightTuple)args[1], (LeftTuple)args[2], (LeftTuple)args[3], (LeftTupleSink)args[4], ((Boolean)args[5]).booleanValue() );
                }
            });            
           
           
                          //Mockito.doCallRealMethod().when( mockedSink ).createLeftTuple( (LeftTuple) null, null, null);
View Full Code Here

                       
                    }

                    // we always lookup from the first element, in case it's indexed
                    List<InternalFactHandle> first = (List<InternalFactHandle>) expectedLeftTuples.get( 0 );
                    LeftTuple firstTuple = new LeftTupleImpl( first.get( 0 ),
                                                              null,
                                                              false);
                    for ( int i = 1; i < first.size(); i++ ) {
                        firstTuple = new LeftTupleImpl( firstTuple,
                                                        new RightTuple( first.get( i )),
                                                        null,
                                                        false );
                    }
View Full Code Here

                    }

                    // create expected tuples
                    List<LeftTuple> leftTuples = new ArrayList<LeftTuple>();
                    for ( List<InternalFactHandle> tlist : (List<List<InternalFactHandle>>) expectedLeftTuples ) {
                        LeftTuple tuple = new LeftTupleImpl( tlist.get( 0 ),
                                                         null,
                                                         false );
                        for ( int i = 1; i < tlist.size(); i++ ) {
                            tuple = new LeftTupleImpl( tuple,
                                                   new RightTuple( tlist.get( i ) ),
                                                   null,
                                                   false );
                        }
                        leftTuples.add( tuple );
View Full Code Here

                                  List<InternalFactHandle> tlist) {
        LeftTuple tuple = null;
        String id = getTupleId( tlist );
        for ( InternalFactHandle handle : tlist ) {
            if ( tuple == null ) {
                tuple = new LeftTupleImpl( handle,
                                           null,
                                           false ); // do not keep generated tuples on the handle list
            } else {
                tuple = new LeftTupleImpl( tuple,
                                           new RightTuple( handle ),
                                           null,
                                           true );
            }
        }
View Full Code Here

        final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 0,
                                                                         cheddar );

        assertEquals( 0,
                      map.size() );
        assertNull( map.get( new LeftTupleImpl( cheddarHandle1,
                                            null,
                                            true ), cheddarHandle1 ) );

        final Cheese stilton1 = new Cheese( "stilton",
                                            35 );
        RightTuple stiltonRighTuple = new RightTuple( new DefaultFactHandle( 1,
                                                                             stilton1 ),
                                                      null );

        map.add( stiltonRighTuple );

        assertEquals( 1,
                      map.size() );
        assertEquals( 1,
                      tablePopulationSize( map ) );

        final Cheese stilton2 = new Cheese( "stilton",
                                            80 );
        final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
                                                                         stilton2 );

        final RightTupleList list = map.get( new LeftTupleImpl( stiltonHandle2,
                                                            null,
                                                            true ), stiltonHandle2 );
        assertSame( stiltonRighTuple.getFactHandle(),
                    list.first.getFactHandle() );
        assertNull( list.first.getNext() );
View Full Code Here

        final Cheese stilton2 = new Cheese( "stilton",
                                            77 );
        final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
                                                                         stilton2 );
        RightTupleList list = map.get( new LeftTupleImpl( stiltonHandle2,
                                                      null,
                                                      true ),stiltonHandle2 );
        assertSame( stiltonHandle1,
                    list.first.getFactHandle() );
        assertNull( list.first.getNext() );

        final Cheese cheddar2 = new Cheese( "cheddar",
                                            5 );
        final InternalFactHandle cheddarHandle2 = new DefaultFactHandle( 2,
                                                                         cheddar2 );
        list = map.get( new LeftTupleImpl( cheddarHandle2,
                                       null,
                                       true ), cheddarHandle2 );
        assertSame( cheddarHandle1,
                    list.first.getFactHandle() );
        assertNull( list.first.getNext() );
View Full Code Here

TOP

Related Classes of org.drools.core.reteoo.LeftTupleImpl

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.