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

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


  public void testBindingList() {
    final RuleModel model = new RuleModel();

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

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

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

    final List b = model.getBoundFacts();
    assertEquals(2, b.size());
View Full Code Here


    final RuleModel model = new RuleModel();

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

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

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

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

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

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

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

    FactPattern pat = new FactPattern();
    pat.boundName = "pat";
    pat.factType = "Person";

    m.addLhsItem(pat);
View Full Code Here

  public void testIsDSLEnhanced() throws Exception {
    RuleModel m = new RuleModel();

    assertFalse(m.hasDSLSentences());

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

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

    assertFalse(m.hasDSLSentences());
View Full Code Here

  public void testRemoveItemLhs() {
    final RuleModel model = new RuleModel();

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

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

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

    assertEquals(3, model.lhs.length);
    assertEquals(x, model.lhs[0]);
View Full Code Here

    // setup the data...

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

    final FactPattern y = new FactPattern("Car");
    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();
View Full Code Here

    assertEquals("y", vars.get(2));
  }

  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);
View Full Code Here

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

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,
                      p.constraintList.constraints[0] );
        assertEquals( y,
View Full Code Here

                      p.constraintList.constraints[1] );

    }
   
    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,
                      p.constraintList.constraints[0] );
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 );

        p.removeConstraint( 1 );

        assertEquals( 1,
                      p.constraintList.constraints.length );

        assertEquals( x,
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.modeldriven.brl.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.