Package org.drools.reteoo

Examples of org.drools.reteoo.BetaNode


        AlphaNode alphaNode = ( AlphaNode ) otnB.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode.getInferredMask());

        ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" );
        BetaNode betaNodeA1 = ( BetaNode ) otnA.getSinkPropagator().getSinks()[0];
        BetaNode betaNodeA2 = ( BetaNode ) otnA.getSinkPropagator().getSinks()[1];

        assertEquals( calculatePositiveMask(list("i"), sp), betaNodeA1.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i"), sp), betaNodeA1.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("b"), sp), betaNodeA1.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), betaNodeA1.getLeftInferredMask() );

        assertEquals( calculatePositiveMask(list("j"), sp), betaNodeA2.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("j"), sp), betaNodeA2.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("c"), sp), betaNodeA2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), betaNodeA2.getLeftInferredMask() );

        ObjectTypeNode otnC = getObjectTypeNode(kbase, "C" );
        BetaNode betaNodeC = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];

        assertEquals( 0L, betaNodeC.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC.getRightInferredMask() );
        assertEquals( -1L, betaNodeC.getLeftDeclaredMask() );
        assertEquals( -1L, betaNodeC.getLeftInferredMask() );

        ObjectTypeNode otnD = getObjectTypeNode(kbase, "D" );
        BetaNode betaNodeD = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];

        assertEquals( 0L, betaNodeD.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeD.getRightInferredMask() );
        assertEquals( -1L, betaNodeD.getLeftDeclaredMask() );
        assertEquals( -1L, betaNodeD.getLeftInferredMask() );

        kbase.removeRule( "org.drools", "r1" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), alphaNode.getInferredMask());
    }
View Full Code Here


            String[] a = args.get( 0 );
            String name = a[0];
            String leftInput = a[1];
            String rightInput = a[2];

            BetaNode betaNode = Mockito.mock( BetaNode.class, Mockito.withSettings().extraInterfaces( DSLMock.class ) );
            Mockito.doAnswer( new Answer<Object>() {
                public Object answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();
                    InternalFactHandle handle = (InternalFactHandle) args[0];
                    BetaNode node = (BetaNode) invocation.getMock();
                    // creating child RightTuple
                    new RightTuple(handle, node);
                    return null;
                }
            }).when( betaNode ).assertObject( any(InternalFactHandle.class),
View Full Code Here

        // first share
        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode1_1.getInferredMask() )
       
        BetaNode betaNode1 = ( BetaNode alphaNode1_1.getSinkPropagator().getSinks()[0];       
        assertEquals( calculatePositiveMask(list("b", "c"), sp), betaNode1.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), betaNode1.getRightInferredMask() );
        assertEquals( calculateNegativeMask(list("!b"), sp), betaNode1.getRightNegativeMask() );

        assertEquals( calculatePositiveMask(list("c"), sp), betaNode1.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("c"), sp), betaNode1.getLeftInferredMask() );
        assertEquals( calculateNegativeMask(list("!a"), sp), betaNode1.getLeftNegativeMask() );

        // second share
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "s"), sp), alphaNode1_2.getInferredMask() )
       

        BetaNode betaNode2 = ( BetaNode alphaNode1_2.getSinkPropagator().getSinks()[0];       
        assertEquals( calculatePositiveMask(list("b", "s"), sp), betaNode2.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i", "b", "s"), sp), betaNode2.getRightInferredMask() );
        assertEquals( calculateNegativeMask(list("!a"), sp), betaNode2.getRightNegativeMask() );

        assertEquals( calculateNegativeMask(list("!a"), sp), betaNode1.getLeftNegativeMask() );
        assertEquals( calculatePositiveMask(list("j"), sp), betaNode2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "j"), sp), betaNode2.getLeftInferredMask() );
        assertEquals( 0L, betaNode2.getLeftNegativeMask() );

        // test rule removal       
        kbase.removeRule( "org.drools", "r0" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "s"), sp), alphaNode1.getInferredMask() );

        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "s"), sp), alphaNode1_2.getInferredMask() );
       
        assertEquals( calculatePositiveMask(list("b", "s"), sp), betaNode2.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i", "b", "s"), sp), betaNode2.getRightInferredMask() );
        assertEquals( calculateNegativeMask(list("!a"), sp), betaNode2.getRightNegativeMask() );

        assertEquals( calculatePositiveMask(list("j"), sp), betaNode2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "j"), sp), betaNode2.getLeftInferredMask() );
        assertEquals( 0L, betaNode2.getLeftNegativeMask() );

        // have to rebuild to remove r1
        kbase = getKnowledgeBase(rule1, rule2);
       
        kbase.removeRule( "org.drools", "r1" );
View Full Code Here

        // first share
        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode1_1.getInferredMask() )
       
        BetaNode betaNode1 = ( BetaNode alphaNode1_1.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("c"), sp), betaNode1.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "b", "c"), sp), betaNode1.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("i"), sp), betaNode1.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "i"), sp), betaNode1.getLeftInferredMask() );       
       
        // second share
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "i", "s", "j"), sp), alphaNode1_2.getInferredMask() )
       

        BetaNode betaNode2 = ( BetaNode alphaNode1_2.getSinkPropagator().getSinks()[1];       
        assertEqualscalculatePositiveMask(list("s"), sp), betaNode2.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "s"), sp), betaNode2.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode2.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "j"), sp), betaNode2.getLeftInferredMask() );        
       
        // third share       
        AlphaNode alphaNode1_4 = ( AlphaNode ) alphaNode1_2.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_4.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "i", "j"), sp), alphaNode1_4.getInferredMask() );         
       

        BetaNode betaNode3 = ( BetaNode alphaNode1_4.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode3.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "b", "j"), sp), betaNode3.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("k"), sp), betaNode3.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("c", "k"), sp), betaNode3.getLeftInferredMask() );       
    }  
View Full Code Here

        // first share
        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "s", "j"), sp), alphaNode1_1.getInferredMask() )
       
        BetaNode betaNode1 = ( BetaNode alphaNode1_1.getSinkPropagator().getSinks()[1];       
        assertEqualscalculatePositiveMask(list("s"), sp), betaNode1.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "s"), sp), betaNode1.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode1.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "j"), sp), betaNode1.getLeftInferredMask() );       

        // second split, third alpha
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1_1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "i", "j"), sp), alphaNode1_2.getInferredMask() );

        BetaNode betaNode3 = ( BetaNode alphaNode1_2.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode3.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "b", "j"), sp), betaNode3.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("k"), sp), betaNode3.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("c", "k"), sp), betaNode3.getLeftInferredMask() );       
    }      
View Full Code Here

        // first split
        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode1_1.getInferredMask() )
       
        BetaNode betaNode1 = ( BetaNode alphaNode1_1.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("c"), sp), betaNode1.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "b", "c"), sp), betaNode1.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("i"), sp), betaNode1.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "i"), sp), betaNode1.getLeftInferredMask() );       
       
        // fist share, second alpha
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "j"), sp), alphaNode1_2.getInferredMask() )
       
        AlphaNode alphaNode1_3 = ( AlphaNode ) alphaNode1_2.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_3.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "b", "j"), sp), alphaNode1_3.getInferredMask() );        
       

        BetaNode betaNode2 = ( BetaNode alphaNode1_3.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode2.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "b", "j"), sp), betaNode2.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("k"), sp), betaNode2.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("c", "k"), sp), betaNode2.getLeftInferredMask() );        
          
    }        
View Full Code Here

        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode1_1.getInferredMask() )
       
        // first split
        BetaNode betaNode1 = ( BetaNode alphaNode1_1.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("c"), sp), betaNode1.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "b", "c"), sp), betaNode1.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("i"), sp), betaNode1.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "i"), sp), betaNode1.getLeftInferredMask() );       
       
        // second split
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "s"), sp), alphaNode1_2.getInferredMask() );          
       

        BetaNode betaNode2 = ( BetaNode alphaNode1_2.getSinkPropagator().getSinks()[0];       
        assertEqualscalculatePositiveMask(list("s"), sp), betaNode2.getRightDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i", "s"), sp), betaNode2.getRightInferredMask() );
       
        assertEqualscalculatePositiveMask(list("j"), sp), betaNode2.getLeftDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "j"), sp), betaNode2.getLeftInferredMask() );           
    }   
View Full Code Here

        ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" );
        ObjectTypeNode otnC = getObjectTypeNode(kbase, "C" );
        List<String> sp = getSettableProperties(wm, otnA);

        BetaNode betaNodeA = ( BetaNode ) otnA.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("i", "b", "c"), sp), betaNodeA.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i", "b", "c"), sp), betaNodeA.getRightInferredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeA.getLeftDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeA.getLeftInferredMask() );

        BetaNode betaNodeC = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];
        assertEquals( 0L, betaNodeC.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("k"), sp), betaNodeC.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "k"), sp), betaNodeC.getLeftInferredMask() );
    }
View Full Code Here

        ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" );
        ObjectTypeNode otnC = getObjectTypeNode(kbase, "C" );
        List<String> sp = getSettableProperties(wm, otnA);

        BetaNode betaNodeA = ( BetaNode ) otnA.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("i", "b", "c"), sp), betaNodeA.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i", "b", "c"), sp), betaNodeA.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("k"), sp), betaNodeA.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "k"), sp), betaNodeA.getLeftInferredMask() );

        BetaNode betaNodeC = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];
        assertEquals(0L, betaNodeC.getRightDeclaredMask());
        assertEquals( 0L, betaNodeC.getRightInferredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeC.getLeftDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeC.getLeftInferredMask() );
    }
View Full Code Here

        AlphaNode alphaNode = ( AlphaNode ) otnB.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode.getInferredMask());

        ObjectTypeNode otnC = getObjectTypeNode(kbase, "C" );
        BetaNode betaNodeC1 = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];
        BetaNode betaNodeC2 = ( BetaNode ) otnC.getSinkPropagator().getSinks()[1];

        LeftInputAdapterNode lia = (LeftInputAdapterNode)alphaNode.getSinkPropagator().getSinks()[0];
        assertSame(betaNodeC1, lia.getSinkPropagator().getSinks()[0]);
        assertSame(betaNodeC2, lia.getSinkPropagator().getSinks()[1]);

        assertEquals( 0L, betaNodeC1.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC1.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("b"), sp), betaNodeC1.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), betaNodeC1.getLeftInferredMask() );

        assertEquals( 0L, betaNodeC2.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC2.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("c"), sp), betaNodeC2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), betaNodeC2.getLeftInferredMask() );

        kbase.removeRule( "org.drools", "r0" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), alphaNode.getInferredMask());

        assertEquals( 1, lia.getSinkPropagator().getSinks().length );
        BetaNode betaNodeC = ( BetaNode ) lia.getSinkPropagator().getSinks()[0];

        assertEquals( 0L, betaNodeC2.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC2.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("c"), sp), betaNodeC2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), betaNodeC2.getLeftInferredMask() );
View Full Code Here

TOP

Related Classes of org.drools.reteoo.BetaNode

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.