Package org.drools.ide.common.client.modeldriven.testing

Examples of org.drools.ide.common.client.modeldriven.testing.Scenario


    }

    @Test
    public void testCallMethodOnStandardArgumentOnFact() throws Exception {

        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        runner.getPopulatedData().put( "cheese",
View Full Code Here


    }

    @Test
    public void testCallMethodOnClassArgumentOnFact() throws Exception {

        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        runner.getPopulatedData().put( "cheese",
View Full Code Here

    }

    @Test
    public void testCallMethodOnClassArgumentAndOnArgumentStandardOnFact() throws Exception {

        ScenarioRunner runner = new ScenarioRunner( new Scenario(),
                                                    null,
                                                    new MockWorkingMemory() );
        Cheesery listChesse = new Cheesery();
        listChesse.setTotalAmount( 1000 );
        runner.getPopulatedData().put( "cheese",
View Full Code Here

      }
      return xt.toXML(sc);
    }

    public Scenario unmarshal(String xml) {
      if (xml == null) return new Scenario();
      if (xml.trim().equals("")) return new Scenario();
      return (Scenario) xt.fromXML(xml);
    }
View Full Code Here

      }
      return xt.toXML(sc);
    }

    public Scenario unmarshal(String xml) {
      if (xml == null) return new Scenario();
      if (xml.trim().equals("")) return new Scenario();
      return (Scenario) xt.fromXML(xml);
    }
View Full Code Here

public class ScenarioXMLPersistenceTest extends TestCase {

  public void testToXML() {
    ScenarioXMLPersistence p = ScenarioXMLPersistence.getInstance();

    Scenario sc = new Scenario();

    String s = p.marshal(sc);
    assertNotNull(s);

    sc = getDemo();

    s = p.marshal(sc);

      assertTrue(s.indexOf("<ruleName>Life unverse and everything</ruleName>") > 0);

      Scenario sc_ = p.unmarshal(s);
      assertEquals(sc.globals.size(), sc_.globals.size());
      assertEquals(sc.fixtures.size(), sc_.fixtures.size());
      assertTrue(s.indexOf("org.drools") == -1); //check we have aliased all

  }
View Full Code Here

      assertTrue(s.indexOf("org.drools") == -1); //check we have aliased all

  }

  public void testTrimUneededSection() {
    Scenario sc = getDemo();
    Scenario orig = getDemo();
    sc.fixtures.add(new ExecutionTrace());

    int origSize = orig.fixtures.size();

    assertEquals(origSize + 1, sc.fixtures.size());
    String xml = ScenarioXMLPersistence.getInstance().marshal(sc);
    Scenario sc_ = ScenarioXMLPersistence.getInstance().unmarshal(xml);

    assertEquals(origSize, sc_.fixtures.size());


View Full Code Here

  }


  public void testNewScenario() {
        FactData d1 = new FactData("Driver", "d1", ls(new FieldData[] {new FieldData("age", "42"), new FieldData("name", "david")}), false);
        Scenario sc = new Scenario();
        sc.fixtures.add(d1);
        sc.fixtures.add(new ExecutionTrace());

        int size = sc.fixtures.size();

    String xml = ScenarioXMLPersistence.getInstance().marshal(sc);
    Scenario sc_ = ScenarioXMLPersistence.getInstance().unmarshal(xml);

    assertEquals(size, sc_.fixtures.size());

    sc = new Scenario();
    sc.fixtures.add(new ExecutionTrace());
    xml = ScenarioXMLPersistence.getInstance().marshal(sc);
    sc_ = ScenarioXMLPersistence.getInstance().unmarshal(xml);
    assertEquals(1, sc_.fixtures.size());
  }
View Full Code Here

        //Sample data
        FactData d1 = new FactData("Driver", "d1", ls(new FieldData[] {new FieldData("age", "42"), new FieldData("name", "david")}), false);
        FactData d2 = new FactData("Driver", "d2", ls(new FieldData[] {new FieldData("name", "michael")}), false);
        FactData d3 = new FactData("Driver", "d3", ls(new FieldData[] {new FieldData("name", "michael2")}), false);
        FactData d4 = new FactData("Accident", "a1", ls(new FieldData[] {new FieldData("name", "michael2")}), false);
        Scenario sc = new Scenario();
        sc.fixtures.add(d1);
        sc.fixtures.add(d2);
        sc.globals.add(d3);
        sc.globals.add(d4);
        sc.rules.add("rule1");
View Full Code Here

    }

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

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

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

        sc.removeExecutionTrace( ex2 );

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

TOP

Related Classes of org.drools.ide.common.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.