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

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


    @Override
    public void storeAssetContent(Asset asset,
                                  AssetItem repoAsset)
                                                      throws SerializationException {
        Scenario sc = (Scenario) asset.getContent();
        repoAsset.updateContent( ScenarioXMLPersistence.getInstance().marshal( sc ) );
    }
View Full Code Here


        while (it.hasNext()) {
            AssetItem as = it.next();
            if (!as.getDisabled()) {
                Asset asset = repositoryAssetOperations.loadAsset(as);
                Scenario sc = (Scenario) asset.getContent();
                runScenario(packageItem.getName(),
                        sc,
                        coverage);

                int[] totals = sc.countFailuresTotal();
                resultSummaries.add(new ScenarioResultSummary(totals[0],
                        totals[1],
                        asset.getName(),
                        asset.getDescription(),
                        asset.getUuid()));
View Full Code Here

    @Test
    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.getGlobals().size(), sc_.getGlobals().size());
      assertEquals(sc.getFixtures().size(), sc_.getFixtures().size());
      assertTrue(s.indexOf("org.drools") == -1); //check we have aliased all

  }
View Full Code Here

  }

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

    int origSize = orig.getFixtures().size();

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

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




View Full Code Here


    @Test
    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.getFixtures().add(d1);
        sc.getFixtures().add(new ExecutionTrace());

        int size = sc.getFixtures().size();

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

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

    sc = new Scenario();
    sc.getFixtures().add(new ExecutionTrace());
    xml = ScenarioXMLPersistence.getInstance().marshal(sc);
    sc_ = ScenarioXMLPersistence.getInstance().unmarshal(xml);
    assertEquals(1, sc_.getFixtures().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.getFixtures().add(d1);
        sc.getFixtures().add(d2);
        sc.getGlobals().add(d3);
        sc.getGlobals().add(d4);
        sc.getRules().add("rule1");
        sc.getRules().add("rule2");

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

        List fields = new ArrayList();
        VerifyField vfl = new VerifyField("age", "42", "==");
        vfl.setActualResult( "43" );
        vfl.setSuccessResult( new Boolean(false) );
        vfl.setExplanation( "Not cool jimmy." );

        fields.add(vfl);

        vfl = new VerifyField("name", "michael", "!=");
        vfl.setActualResult( "bob" );
        vfl.setSuccessResult( new Boolean(true) );
        vfl.setExplanation( "Yeah !" );
        fields.add(vfl);

        VerifyFact vf = new VerifyFact("d1", fields);

        sc.getFixtures().add(vf);

        VerifyRuleFired vf1 = new VerifyRuleFired("Life unverse and everything", new Integer(42), null);
        vf1.setActualResult( new Integer(42) );
        vf1.setSuccessResult( new Boolean(true) );
        vf1.setExplanation( "All good here." );

        VerifyRuleFired vf2 = new VerifyRuleFired("Everything else", null, new Boolean(true));
        vf2.setActualResult( new Integer(0) );
        vf2.setSuccessResult( new Boolean(false) );
        vf2.setExplanation( "Not so good here." );
        sc.getFixtures().add(vf1);
        sc.getFixtures().add(vf2);

    return sc;
  }
View Full Code Here

        DroolsMVELFactory d = new DroolsMVELFactory();
    }

    @Test
    public void testPopulateFactsWithInterfaces() throws Exception {
        Scenario sc = new Scenario();
        List facts = ls( new FactData( "List",
                                       "ls",
                                       new ArrayList(),
                                       false ) );

        List globals = ls( new FactData( "List",
                                         "ls",
                                         new ArrayList(),
                                         false ) );
        sc.getFixtures().addAll( facts );
        sc.getGlobals().addAll( globals );
        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "java.util.List" );

        ScenarioRunner runner = new ScenarioRunner( sc,
View Full Code Here

    }

    @Test
    public void testPopulateFacts() throws Exception {
        Scenario sc = new Scenario();
        List facts = ls( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "type",
                                                          "cheddar" ),
                                           new FieldData( "price",
                                                          "42" ) ),
                                       false ),
                         new FactData( "Person",
                                       "p1",
                                       ls( new FieldData( "name",
                                                          "mic" ),
                                           new FieldData( "age",
                                                          "=30 + 3" ) ),
                                       false ) );

        sc.getFixtures().addAll( facts );
        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.Cheese" );
        resolver.addImport( "org.drools.Person" );
        ScenarioRunner runner = new ScenarioRunner( sc,
View Full Code Here

    }

    @Test
    public void testPopulateEnum() throws Exception {
        Scenario sc = new Scenario();
        FieldData fd = new FieldData( "cheeseType",
                                      "CheeseType.CHEDDAR" );
        fd.setNature( FieldData.TYPE_ENUM,
                      null );
        List facts = ls( new FactData( "Cheese",
                                       "c1",
                                       ls( fd ),
                                       false ) );

        sc.getFixtures().addAll( facts );
        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.Cheese" );
        resolver.addImport( "org.drools.CheeseType" );
        ScenarioRunner runner = new ScenarioRunner( sc,
View Full Code Here

                      c.getCheeseType() );
    }

    @Test
    public void testPopulateNested() throws Exception {
        Scenario sc = new Scenario();
        List facts = ls( new FactData( "Cheese",
                                       "c1",
                                       ls( new FieldData( "type",
                                                          "cheddar" ),
                                           new FieldData( "price",
                                                          "42" ) ),
                                       false ),
                         new FactData( "OuterFact",
                                       "p1",
                                       ls( new FieldData( "name",
                                                          "mic" ),
                                           new FieldData( "innerFact",
                                                          "=c1" ) ),
                                       false ) );

        sc.getFixtures().addAll( facts );
        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.Cheese" );
        resolver.addImport( "org.drools.OuterFact" );
        ScenarioRunner runner = new ScenarioRunner( sc,
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.