Package org.drools.guvnor.client.modeldriven.brl

Examples of org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint


    model.lhs = new IPattern[2];
    final FactPattern x = new FactPattern("Car");
    model.lhs[0] = x;
    x.boundName = "boundFact";

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

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

    model.lhs[1] = new CompositeFactPattern();
View Full Code Here


    model.lhs[1] = y;
    y.boundName = "y";
    final SingleFieldConstraint[] cons = new SingleFieldConstraint[2];
    y.constraintList = new CompositeFieldConstraint();
    y.constraintList.constraints = cons;
    cons[0] = new SingleFieldConstraint("age");
    cons[1] = new SingleFieldConstraint("make");
    cons[0].fieldBinding = "qbc";
    cons[0].connectives = new ConnectiveConstraint[1];
    cons[0].connectives[0] = new ConnectiveConstraint("&", "x");
    cons[0].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;

    final FactPattern other = new FactPattern("House");
    model.lhs[2] = other;
    other.boundName = "q";
    final SingleFieldConstraint[] cons2 = new SingleFieldConstraint[1];
    cons2[0] = new SingleFieldConstraint();
    other.constraintList = new CompositeFieldConstraint();
    other.constraintList.constraints = cons2;

    // check the results for correct scope
    List vars = model.getBoundVariablesInScope(cons[0]);
View Full Code Here

  public void testScopedVariablesWithCompositeFact() {
    RuleModel m = new RuleModel();
    FactPattern p = new FactPattern();
    CompositeFieldConstraint cf = new CompositeFieldConstraint();
    cf.addConstraint(new SingleFieldConstraint("x"));
    p.addConstraint(cf);
    SingleFieldConstraint sf = new SingleFieldConstraint("q");
    sf.fieldBinding = "abc";

    p.addConstraint(sf);
    SingleFieldConstraint sf2 = new SingleFieldConstraint("q");
    sf2.fieldBinding = "qed";
    cf.addConstraint(sf2);
    m.addLhsItem(p);

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

import org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint;

public class ConstraintTest extends TestCase {

    public void testAdd() {
        final SingleFieldConstraint con = new SingleFieldConstraint();
        con.addNewConnective();

        assertEquals( 1,
                      con.connectives.length );
        assertNotNull( con.connectives[0] );

        con.addNewConnective();

        assertEquals( 2,
                      con.connectives.length );
        assertNotNull( con.connectives[1] );
View Full Code Here

public class FactPatternTest extends TestCase {

    public void testAddConstraint() {
        final FactPattern p = new FactPattern();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );

        assertEquals( 1,
                      p.constraintList.constraints.length );
        assertEquals( x,
                      p.constraintList.constraints[0] );

        final SingleFieldConstraint y = new SingleFieldConstraint( "y" );

        p.addConstraint( y );
        assertEquals( 2,
                      p.constraintList.constraints.length );
        assertEquals( x,
View Full Code Here

    }
   
    public void testWithCompositeNesting() {
        final FactPattern p = new FactPattern();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );

        assertEquals( 1,
                      p.constraintList.constraints.length );
        assertEquals( x,
                      p.constraintList.constraints[0] );

        final CompositeFieldConstraint y = new CompositeFieldConstraint();

        y.addConstraint( new SingleFieldConstraint("y") );
        y.addConstraint( new SingleFieldConstraint("z") );       
        p.addConstraint( y );
       
        assertEquals( 2,
                      p.constraintList.constraints.length );
        assertEquals( x,
View Full Code Here

       
    }

    public void testRemoveConstraint() {
        final FactPattern p = new FactPattern();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );
        final SingleFieldConstraint y = new SingleFieldConstraint( "y" );
        p.addConstraint( y );

        assertEquals( 2,
                      p.constraintList.constraints.length );
View Full Code Here

    public void testGetFieldConstraints() {
        FactPattern pat = new FactPattern();
        assertEquals(0, pat.getFieldConstraints().length);
        assertNull(pat.constraintList);
       
        pat.addConstraint( new SingleFieldConstraint() );
        assertNotNull(pat.constraintList);
        assertEquals(1, pat.getFieldConstraints().length);
    }
View Full Code Here

        assertEquals(null, con.compositeJunctionType);
    }
   
    public void testAddConstraint() {
        final CompositeFieldConstraint p = new CompositeFieldConstraint();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );

        assertEquals( 1,
                      p.constraints.length );
        assertEquals( x,
                      p.constraints[0] );

        final SingleFieldConstraint y = new SingleFieldConstraint( "y" );

        p.addConstraint( y );
        assertEquals( 2,
                      p.constraints.length );
        assertEquals( x,
View Full Code Here

    }

    public void testRemoveConstraint() {
        final CompositeFieldConstraint p = new CompositeFieldConstraint();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );
        final CompositeFieldConstraint y = new CompositeFieldConstraint(  );
        p.addConstraint( y );

        assertEquals( 2,
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint

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.