Package org.drools.guvnor.client.modeldriven.testing

Examples of org.drools.guvnor.client.modeldriven.testing.FactData


   
   
    public void testIntegrationInfiniteLoop() throws Exception {

        Scenario sc = new Scenario();
        FactData[] facts = new FactData[]{new FactData( "Cheese",
                                                        "c1",
                                                        ls( new FieldData( "type",
                                                                           "cheddar" ),
                                                            new FieldData( "price",
                                                                           "42" ) ),
                                                        false )

        };
        sc.globals.add( new FactData( "Person",
                                      "p",
                                      new ArrayList(),
                                      false ) );
        sc.fixtures.addAll( Arrays.asList( facts ) );
View Full Code Here


    }

    public void testIntegrationWithDeclaredTypes() throws Exception {
        Scenario sc = new Scenario();
        FactData[] facts = new FactData[]{new FactData( "Coolness",
                                                        "c",
                                                        ls( new FieldData( "num",
                                                                           "42" ),
                                                            new FieldData( "name",
                                                                           "mic" ) ),
View Full Code Here

    }

    public void testIntgerationStateful() throws Exception {
        Scenario sc = new Scenario();
        sc.fixtures.add( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "price",
                                                          "1" ) ),
                                       false ) );
        ExecutionTrace ex = new ExecutionTrace();
        sc.fixtures.add( ex );
        sc.fixtures.add( new FactData( "Cheese",
                                       "c2",
                                       ls( new FieldData( "price",
                                                          "2" ) ),
                                       false ) );
        sc.fixtures.add( new VerifyFact( "c1",
View Full Code Here

    }

    public void testIntegrationWithModify() throws Exception {
        Scenario sc = new Scenario();
        sc.fixtures.add( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "price",
                                                          "1" ) ),
                                       false ) );

        sc.fixtures.add( new ExecutionTrace() );

        sc.fixtures.add( new VerifyFact( "c1",
                                         ls( new VerifyField( "type",
                                                              "rule1",
                                                              "==" ) ) ) );

        sc.fixtures.add( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "price",
                                                          "42" ) ),
                                       true ) );
        sc.fixtures.add( new ExecutionTrace() );
View Full Code Here

        assertTrue( sc.wasSuccessful() );
    }

    public void testIntegrationWithRetract() throws Exception {
        Scenario sc = new Scenario();
        sc.fixtures.add( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "price",
                                                          "46" ),
                                           new FieldData( "type",
                                                          "XXX" ) ),
                                       false ) );
        sc.fixtures.add( new FactData( "Cheese",
                                       "c2",
                                       ls( new FieldData( "price",
                                                          "42" ) ),
                                       false ) );
        sc.fixtures.add( new ExecutionTrace() );
View Full Code Here

      assertFalse("".equals(failures));
      System.err.println(failures);
    }

  private Expectation[] populateScenarioForFailure(Scenario sc) {
    FactData[] facts = new FactData[]{new FactData( "Cheese",
                                                        "c1",
                                                        ls( new FieldData( "type",
                                                                           "cheddar" ),
                                                            new FieldData( "price",
                                                                           "42" ) ),
                                                        false )

        };
        sc.fixtures.addAll( Arrays.asList( facts ) );
        sc.globals.add( new FactData( "Person",
                                      "p",
                                      new ArrayList(),
                                      false ) );

        ExecutionTrace executionTrace = new ExecutionTrace();
View Full Code Here

    TestingEventListener listener = null;

        List<Populate> toPopulate = new ArrayList<Populate>();

    for (Iterator iterator = scenario.globals.iterator(); iterator.hasNext();) {
      final FactData fact = (FactData) iterator.next();
      final Object f = eval("new " + getTypeName(resolver, fact) + "()");
            toPopulate.add(new Populate() {
                public void go() {
                    populateFields(fact, globalData, f);
                }
            });
      globalData.put(fact.name, f);
      wm.setGlobal(fact.name, f);
    }

        doPopulate(toPopulate);

    for (Iterator<Fixture> iterator = scenario.fixtures.iterator(); iterator.hasNext();) {
      Fixture fx = iterator.next();

      if (fx instanceof FactData) {
        //deal with facts and globals
        final FactData fact = (FactData)fx;
        final Object f = (fact.isModify)? this.populatedData.get(fact.name) : eval("new " + getTypeName(resolver, fact) + "()");
        if (fact.isModify) {
          if (!this.factHandles.containsKey(fact.name)) {
            throw new IllegalArgumentException("Was not a previously inserted fact. [" + fact.name  + "]");
          }
View Full Code Here

    //TestingEventListener.stubOutRules(ruleList, wm.getRuleBase(), scenario.inclusive);

    TestingEventListener listener = null;

    for (Iterator iterator = scenario.globals.iterator(); iterator.hasNext();) {
      FactData fact = (FactData) iterator.next();
      Object f = eval("new " + getTypeName(resolver, fact) + "()");
      populateFields(fact, globalData, f);
      globalData.put(fact.name, f);
      wm.setGlobal(fact.name, f);
    }

    for (Iterator<Fixture> iterator = scenario.fixtures.iterator(); iterator.hasNext();) {
      Fixture fx = iterator.next();

      if (fx instanceof FactData) {
        //deal with facts and globals
        FactData fact = (FactData)fx;
        Object f = (fact.isModify)? this.populatedData.get(fact.name) : eval("new " + getTypeName(resolver, fact) + "()");
        if (fact.isModify) {
          if (!this.factHandles.containsKey(fact.name)) {
            throw new IllegalArgumentException("Was not a previously inserted fact. [" + fact.name  + "]");
          }
View Full Code Here

    TestingEventListener listener = null;

        List<Populate> toPopulate = new ArrayList<Populate>();

    for (Iterator iterator = scenario.globals.iterator(); iterator.hasNext();) {
      final FactData fact = (FactData) iterator.next();
      final Object f = eval("new " + getTypeName(resolver, fact) + "()");
            toPopulate.add(new Populate() {
                public void go() {
                    populateFields(fact, globalData, f);
                }
            });
      globalData.put(fact.name, f);
      wm.setGlobal(fact.name, f);
    }

        doPopulate(toPopulate);

    for (Iterator<Fixture> iterator = scenario.fixtures.iterator(); iterator.hasNext();) {
      Fixture fx = iterator.next();

      if (fx instanceof FactData) {
        //deal with facts and globals
        final FactData fact = (FactData)fx;
        final Object f = (fact.isModify)? this.populatedData.get(fact.name) : eval("new " + getTypeName(resolver, fact) + "()");
        if (fact.isModify) {
          if (!this.factHandles.containsKey(fact.name)) {
            throw new IllegalArgumentException("Was not a previously inserted fact. [" + fact.name  + "]");
          }
View Full Code Here

import org.drools.guvnor.client.modeldriven.testing.FactData;
import org.drools.guvnor.client.modeldriven.testing.FieldData;

public class FactDataTest extends TestCase {
  public void testAdd() {
    FactData fd = new FactData("x", "y", new ArrayList(), false );
    assertEquals(0, fd.fieldData.size());
    fd.fieldData.add(new FieldData("x", "y"));
    assertEquals(1, fd.fieldData.size());
    fd.fieldData.add(new FieldData("q", "x"));
    assertEquals(2, fd.fieldData.size());
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.modeldriven.testing.FactData

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.