Package org.drools.guvnor.models.commons.shared.rule

Examples of org.drools.guvnor.models.commons.shared.rule.FactPattern


        //LHS
        assertEquals( 1,
                      m.lhs.length );
        assertTrue( m.lhs[ 0 ] instanceof FactPattern );

        final FactPattern p = (FactPattern) m.lhs[ 0 ];
        assertEquals( "$a",
                      p.getBoundName() );
        assertEquals( "Applicant",
                      p.getFactType() );

        //RHS
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionSetField );
View Full Code Here


        //LHS
        assertEquals( 1,
                      m.lhs.length );
        assertTrue( m.lhs[ 0 ] instanceof FactPattern );

        final FactPattern p = (FactPattern) m.lhs[ 0 ];
        assertEquals( "$a",
                      p.getBoundName() );
        assertEquals( "Applicant",
                      p.getFactType() );

        //RHS
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionCallMethod );
View Full Code Here

        //LHS
        assertEquals( 1,
                      m.lhs.length );
        assertTrue( m.lhs[ 0 ] instanceof FactPattern );

        final FactPattern p = (FactPattern) m.lhs[ 0 ];
        assertEquals( "$a",
                      p.getBoundName() );
        assertEquals( "Applicant",
                      p.getFactType() );

        //RHS
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionGlobalCollectionAdd );
View Full Code Here

        assertEquals( 3,
                      m.lhs.length );

        //Condition line 1
        assertTrue( m.lhs[ 0 ] instanceof FactPattern );
        final FactPattern fp1 = (FactPattern) m.lhs[ 0 ];
        assertEquals( "$a",
                      fp1.getBoundName() );
        assertEquals( "Applicant",
                      fp1.getFactType() );

        //Condition line 2
        assertTrue( m.lhs[ 1 ] instanceof FreeFormLine );
        final FreeFormLine ffl = (FreeFormLine) m.lhs[ 1 ];
        assertEquals( "Here's something typed by the user as free-format DRL",
                      ffl.getText() );

        //Condition line 3
        assertTrue( m.lhs[ 2 ] instanceof FactPattern );
        final FactPattern fp2 = (FactPattern) m.lhs[ 2 ];
        assertEquals( "$b",
                      fp2.getBoundName() );
        assertEquals( "Bananna",
                      fp2.getFactType() );
    }
View Full Code Here

        //LHS
        assertEquals( 1,
                      m.lhs.length );

        assertTrue( m.lhs[ 0 ] instanceof FactPattern );
        final FactPattern fp1 = (FactPattern) m.lhs[ 0 ];
        assertEquals( "$a",
                      fp1.getBoundName() );
        assertEquals( "Applicant",
                      fp1.getFactType() );

        //RHS
        assertEquals( 2,
                      m.rhs.length );
View Full Code Here

public class RuleModelTest {

    @Test
    public void testAddItemLhs() {
        final RuleModel model = new RuleModel();
        final FactPattern x = new FactPattern();
        model.addLhsItem( x );
        assertEquals( 1,
                model.lhs.length );

        final FactPattern y = new FactPattern();
        model.addLhsItem( y );

        assertEquals( 2,
                model.lhs.length );
        assertEquals( x,
View Full Code Here

    @Test
    public void testAllVariableBindings() {
        final RuleModel model = new RuleModel();
        model.lhs = new IPattern[2];
        final FactPattern x = new FactPattern( "Car" );
        model.lhs[0] = x;
        x.setBoundName( "boundFact" );

        SingleFieldConstraint sfc = new SingleFieldConstraint( "q" );
        x.addConstraint( sfc );
        sfc.setFieldBinding( "field1" );

        SingleFieldConstraint sfc2 = new SingleFieldConstraint( "q" );
        x.addConstraint( sfc2 );
        sfc2.setFieldBinding( "field2" );

        model.lhs[1] = new CompositeFactPattern();

        List vars = model.getAllVariables();
View Full Code Here

    @Test
    public void testAllVariableBindings2() {
        final RuleModel model = new RuleModel();
        model.lhs = new IPattern[1];
        final FactPattern fp = new FactPattern( "Car" );
        model.lhs[0] = fp;
        fp.setBoundName( "$c" );

        SingleFieldConstraint sfc = new SingleFieldConstraintEBLeftSide( "make" );
        sfc.getExpressionValue().appendPart( new ExpressionField( "make",
                "java.lang.String",
                "String" ) );
        sfc.setFieldBinding( "$m" );
        fp.addConstraint( sfc );

        List<String> vars = model.getAllVariables();
        assertEquals( 2,
                vars.size() );
        assertEquals( "$c",
View Full Code Here

        final RuleModel model = new RuleModel();

        assertNull( model.getLHSBoundFact( "x" ) );
        model.lhs = new IPattern[3];

        final FactPattern x = new FactPattern( "Car" );
        model.lhs[0] = x;
        x.setBoundName( "x" );

        assertNotNull( model.getLHSBoundFact( "x" ) );
        assertEquals( x,
                model.getLHSBoundFact( "x" ) );

        final FactPattern y = new FactPattern( "Car" );
        model.lhs[1] = y;
        y.setBoundName( "y" );

        final FactPattern other = new FactPattern( "House" );
        model.lhs[2] = other;

        assertEquals( y,
                model.getLHSBoundFact( "y" ) );
        assertEquals( x,
View Full Code Here

    @Test
    public void testGetVariableNameForRHS() {
        RuleModel m = new RuleModel();
        m.name = "blah";

        FactPattern pat = new FactPattern( "Person" );
        pat.setBoundName( "pat" );

        m.addLhsItem( pat );

        List l = m.getAllVariables();
        assertEquals( 1,
View Full Code Here

TOP

Related Classes of org.drools.guvnor.models.commons.shared.rule.FactPattern

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.