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

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


    }

    public void testVerifyAnonymousFacts() throws Exception {
      MockWorkingMemory wm = new MockWorkingMemory();
        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                null,
                wm );

        Cheese c = new Cheese();
        c.setPrice(42);
View Full Code Here


        assertEquals(Boolean.FALSE, ((VerifyField)vf.fieldValues.get(0)).successResult);

    }

    public void testVerifyFactsWithOperator() throws Exception {
        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheese f1 = new Cheese( "cheddar",
                                42 );
        runner.populatedData.put( "f1",
View Full Code Here

        assertFalse( ((VerifyField) vf.fieldValues.get( 0 )).successResult );

    }

    public void testVerifyFactsWithExpression() throws Exception {
        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheese f1 = new Cheese( "cheddar",
                                42 );
        runner.populatedData.put( "f1",
View Full Code Here

        assertTrue( ((VerifyField) vf.fieldValues.get( 0 )).successResult );
    }

    public void testVerifyFactExplanation() throws Exception {
        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheese f1 = new Cheese();
        f1.setType( null );
        runner.populatedData.put( "f1",
View Full Code Here

                      vfl.explanation );

    }

    public void testVerifyFieldAndActualIsNull() throws Exception {
        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheese f1 = new Cheese();
        f1.setType( null );
        runner.populatedData.put( "f1",
View Full Code Here

                      vfl.actualResult );

    }

    public void testDummyRunNoRules() throws Exception {
        Scenario sc = new Scenario();
        FactData[] facts = new FactData[]{new FactData( "Cheese",
                                                        "c1",
                                                        ls( new FieldData( "type",
                                                                           "cheddar" ),
                                                            new FieldData( "price",
View Full Code Here

                          2 );
        firingCounts.put( "bar",
                          1 );
        // and baz, we leave out

        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        VerifyRuleFired v = new VerifyRuleFired();
        v.ruleName = "foo";
        v.expectedFire = true;
View Full Code Here

import org.drools.guvnor.client.modeldriven.testing.VerifyRuleFired;

public class ScenarioTest extends TestCase {

  public void testInsertBetween() {
    Scenario sc = new Scenario();
    VerifyRuleFired vf = new VerifyRuleFired();
    sc.insertBetween(null, vf);
    assertEquals(1, sc.fixtures.size());
    assertEquals(vf, sc.fixtures.get(0));

    VerifyRuleFired vf2 = new VerifyRuleFired();
    sc.fixtures.add(vf2);

    VerifyRuleFired vf3 = new VerifyRuleFired();
    sc.insertBetween(vf, vf3);
    assertEquals(3, sc.fixtures.size());
    assertEquals(vf, sc.fixtures.get(0));
    assertEquals(vf2, sc.fixtures.get(1));
    assertEquals(vf3, sc.fixtures.get(2));

    VerifyRuleFired vf4 = new VerifyRuleFired();
    sc.insertBetween(vf2, vf4);
    assertEquals(4, sc.fixtures.size());
    assertEquals(3, sc.fixtures.indexOf(vf4));
    assertEquals(2, sc.fixtures.indexOf(vf3));
    //assertEquals(vf4, sc.fixtures.get(3));
    assertEquals(1, sc.fixtures.indexOf(vf2));
    //assertEquals(vf2, sc.fixtures.get(2));
    assertEquals(0, sc.fixtures.indexOf(vf));


    VerifyRuleFired vf5 = new VerifyRuleFired();
    sc.insertBetween(null, vf5);
    assertEquals(5, sc.fixtures.size());
    assertEquals(4, sc.fixtures.indexOf(vf5));


    sc = new Scenario();

    sc.fixtures.add(vf);
    ExecutionTrace ex = new ExecutionTrace();
    sc.fixtures.add(ex);
    sc.insertBetween(null, vf2);
    assertEquals(0, sc.fixtures.indexOf(vf));
    assertEquals(1, sc.fixtures.indexOf(vf2));
    assertEquals(2, sc.fixtures.indexOf(ex));
    assertEquals(3, sc.fixtures.size());

    sc.insertBetween(ex, vf3);
    assertEquals(4, sc.fixtures.size());
    assertEquals(0, sc.fixtures.indexOf(vf));
    assertEquals(1, sc.fixtures.indexOf(vf2));
    assertEquals(2, sc.fixtures.indexOf(ex));
    assertEquals(3, sc.fixtures.indexOf(vf3));


    ExecutionTrace ex2 = new ExecutionTrace();
    sc.fixtures.add(ex2);
    sc.insertBetween(ex, vf4);
    assertEquals(6, sc.fixtures.size());
    assertEquals(0, sc.fixtures.indexOf(vf));
    assertEquals(1, sc.fixtures.indexOf(vf2));
    assertEquals(2, sc.fixtures.indexOf(ex));
    assertEquals(3, sc.fixtures.indexOf(vf3));
    assertEquals(4, sc.fixtures.indexOf(vf4));
    assertEquals(5, sc.fixtures.indexOf(ex2));


    sc.insertBetween(ex2, vf5);
    assertEquals(7, sc.fixtures.size());
    assertEquals(0, sc.fixtures.indexOf(vf));
    assertEquals(1, sc.fixtures.indexOf(vf2));
    assertEquals(2, sc.fixtures.indexOf(ex));
    assertEquals(3, sc.fixtures.indexOf(vf3));
    assertEquals(4, sc.fixtures.indexOf(vf4));
    assertEquals(5, sc.fixtures.indexOf(ex2));
    assertEquals(6, sc.fixtures.indexOf(vf5));


    sc = new Scenario();
    sc.fixtures.add(ex);

    sc.insertBetween(null, vf);
    assertEquals(2, sc.fixtures.size());
    assertEquals(0, sc.fixtures.indexOf(vf));
    assertEquals(1, sc.fixtures.indexOf(ex));

View Full Code Here

  }



  public void testExecutionTrace() {
        Scenario sc = new Scenario();

        sc.globals.add(new FactData("A", "A", new ArrayList(), false));
        sc.fixtures.add(new FactData("B", "B", new ArrayList(), true));
        sc.fixtures.add(new FactData("C", "C", new ArrayList(), true));
        ExecutionTrace ex1 = new ExecutionTrace();
        sc.fixtures.add(ex1);
        sc.fixtures.add(new VerifyFact());
        sc.fixtures.add(new RetractFact());
        sc.fixtures.add(new FactData("D", "D", new ArrayList(), false));
        sc.fixtures.add(new FactData("E", "E", new ArrayList(), false));
        ExecutionTrace ex2 = new ExecutionTrace();
        sc.fixtures.add(ex2);
        sc.fixtures.add(new VerifyFact());
        sc.fixtures.add(new FactData("F", "F", new ArrayList(), false));
        ExecutionTrace ex3 = new ExecutionTrace();
        sc.fixtures.add(ex3);

        assertEquals( 11,
                      sc.fixtures.size() );

        sc.removeExecutionTrace( ex2 );

        assertEquals( 6,
                      sc.fixtures.size() );
        assertTrue( sc.isFactNameExisting( "A" ) );
        assertTrue( sc.isFactNameExisting( "B" ) );
        assertTrue( sc.isFactNameExisting( "C" ) );
        assertFalse( sc.isFactNameExisting( "D" ) );
        assertFalse( sc.isFactNameExisting( "E" ) );
        assertTrue( sc.isFactNameExisting( "F" ) );
  }
View Full Code Here

        assertFalse( sc.isFactNameExisting( "E" ) );
        assertTrue( sc.isFactNameExisting( "F" ) );
  }

  public void testRemoveFixture() {
    Scenario sc = new Scenario();

    VerifyRuleFired vf1 = new VerifyRuleFired();
    VerifyRuleFired vf2 = new VerifyRuleFired();
    VerifyRuleFired vf3 = new VerifyRuleFired();

    FactData fd = new FactData();

    sc.fixtures.add(vf1);
    sc.fixtures.add(vf2);
    sc.fixtures.add(vf3);
    sc.globals.add(fd);


    sc.removeFixture(vf2);
    assertEquals(2, sc.fixtures.size());
    assertEquals(vf1, sc.fixtures.get(0));
    assertEquals(vf3, sc.fixtures.get(1));
    assertEquals(1, sc.globals.size());

    sc.removeFixture(fd);
    assertEquals(0, sc.globals.size());
    assertEquals(2, sc.fixtures.size());


View Full Code Here

TOP

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

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.