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

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


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

        final ActionSetField a = (ActionSetField) m.rhs[ 0 ];
        assertEquals( "$a",
                      a.getVariable() );
        assertEquals( 1,
                      a.getFieldValues().length );

        final ActionFieldValue fv = a.getFieldValues()[ 0 ];
        assertEquals( "name",
                      fv.getField() );
        assertEquals( "Michael",
                      fv.getValue() );
    }
View Full Code Here


        final FreeFormLine ffl = (FreeFormLine) m.rhs[ 0 ];
        assertEquals( "Here's something typed by the user as free-format DRL",
                ffl.getText() );

        assertTrue( m.rhs[ 1 ] instanceof ActionSetField );
        final ActionSetField a1 = (ActionSetField) m.rhs[ 1 ];
        assertEquals( "$a",
                      a1.getVariable() );
        assertEquals( 2,
                      a1.getFieldValues().length );

        final ActionFieldValue fv1a1 = a1.getFieldValues()[ 0 ];
        assertEquals( "name",
                      fv1a1.getField() );
        assertEquals( "Michael",
                      fv1a1.getValue() );

        final ActionFieldValue fv1a2 = a1.getFieldValues()[ 1 ];
        assertEquals( "age",
                      fv1a2.getField() );
        assertEquals( "40",
                      fv1a2.getValue() );
    }
View Full Code Here

    }

    @Test
    public void testAddItemRhs() {
        final RuleModel model = new RuleModel();
        final IAction a0 = new ActionSetField();
        final IAction a1 = new ActionSetField();

        model.addRhsItem( a0 );

        assertEquals( 1,
                model.rhs.length );
View Full Code Here

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

        model.rhs = new IAction[1];
        final ActionSetField set = new ActionSetField();
        set.setVariable( "x" );
        model.rhs[0] = set;

        assertTrue( model.isBoundFactUsed( "x" ) );
        assertFalse( model.isBoundFactUsed( "y" ) );
View Full Code Here

        assertFalse( m.hasDSLSentences() );

        m.addLhsItem( new FactPattern() );
        assertFalse( m.hasDSLSentences() );

        m.addRhsItem( new ActionSetField( "q" ) );

        assertFalse( m.hasDSLSentences() );

        m.addLhsItem( new DSLSentence() );
        assertTrue( m.hasDSLSentences() );
View Full Code Here

    @Test
    public void testAddItemRhsAtSpecificPosition() {
        final RuleModel model = new RuleModel();

        final ActionSetField a = new ActionSetField();
        model.addRhsItem( a );

        assertEquals( 1,
                model.rhs.length );

        final ActionSetField b = new ActionSetField();
        model.addRhsItem( b );

        assertEquals( 2,
                model.rhs.length );

        final ActionSetField c = new ActionSetField();
        model.addRhsItem( c,
                true );

        assertEquals( 3,
                model.rhs.length );

        assertEquals( a,
                model.rhs[0] );
        assertEquals( b,
                model.rhs[1] );
        assertEquals( c,
                model.rhs[2] );

        final ActionSetField d = new ActionSetField();
        model.addRhsItem( d,
                false );

        assertEquals( 4,
                model.rhs.length );

        assertEquals( d,
                model.rhs[0] );
        assertEquals( a,
                model.rhs[1] );
        assertEquals( b,
                model.rhs[2] );
        assertEquals( c,
                model.rhs[3] );

        final ActionSetField e = new ActionSetField();
        model.addRhsItem( e,
                2 );

        assertEquals( 5,
                model.rhs.length );

        assertEquals( d,
                model.rhs[0] );
        assertEquals( a,
                model.rhs[1] );
        assertEquals( e,
                model.rhs[2] );
        assertEquals( b,
                model.rhs[3] );
        assertEquals( c,
                model.rhs[4] );

        //test auto-bound
        final ActionSetField f = new ActionSetField();
        final ActionSetField g = new ActionSetField();
        model.addRhsItem( f,
                -1 );
        model.addRhsItem( g,
                100 );
View Full Code Here

                model.getAllLHSVariables().size() );
        assertTrue( model.getAllLHSVariables().contains( "x" ) );
        assertTrue( model.getAllLHSVariables().contains( "a" ) );

        model.rhs = new IAction[1];
        final ActionSetField set = new ActionSetField();
        set.setVariable( "x");
        model.rhs[0] = set;

        assertTrue( model.isBoundFactUsed( "x" ) );

        assertEquals( 1,
View Full Code Here

                }
            }
        }

        for ( Map.Entry<String, List<String>> entry : setStatements.entrySet() ) {
            ActionSetField action = new ActionSetField( entry.getKey() );
            addSettersToAction( entry.getValue(), action, isJavaDialect );
            m.addRhsItem( action );
        }

        if ( expandedDRLInfo.hasDsl ) {
View Full Code Here

TOP

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

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.