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

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


        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() );

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

        sc.fixtures.add( new RetractFact( "c2" ) );
        sc.fixtures.add( new ExecutionTrace() );

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

        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.Cheese" );

        WorkingMemory wm = getWorkingMemory( "test_stateful.drl" );
        ScenarioRunner run = new ScenarioRunner( sc,
                                                 resolver,
                                                 (InternalWorkingMemory) wm );

        Cheese c1 = (Cheese) run.populatedData.get( "c1" );

        assertEquals( "rule4",
                      c1.getType() );
        assertFalse( run.populatedData.containsKey( "c2" ) );

        assertTrue( sc.wasSuccessful() );
    }
View Full Code Here


        assertTrue( sc.wasSuccessful() );
    }

    public void testIntegrationWithFailure() throws Exception {
        Scenario sc = new Scenario();
        Expectation[] assertions = populateScenarioForFailure(sc);

        TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
                                                       Thread.currentThread().getContextClassLoader() );
        resolver.addImport( "org.drools.Cheese" );
        resolver.addImport( "org.drools.Person" );

        WorkingMemory wm = getWorkingMemory( "test_rules2.drl" );

        ScenarioRunner run = new ScenarioRunner( sc,
                                                 resolver,
                                                 (InternalWorkingMemory) wm );

        assertSame( run.scenario,
                    sc );

        assertFalse( sc.wasSuccessful() );

        VerifyFact vf = (VerifyFact) assertions[1];
        assertFalse( ((VerifyField) vf.fieldValues.get( 0 )).successResult );
        assertEquals( "XXX",
                      ((VerifyField) vf.fieldValues.get( 0 )).expected );
View Full Code Here

                      vr.actualResult.intValue() );

    }

    public void testRunAsString() throws Exception {
      Scenario sc = new Scenario();
      populateScenarioForFailure(sc);
      String xml = ScenarioXMLPersistence.getInstance().marshal(sc);
      WorkingMemory wm = getWorkingMemory( "test_rules2.drl" );
      ScenarioRunner runner = new ScenarioRunner(xml, wm.getRuleBase());
      assertFalse(runner.wasSuccess());
View Full Code Here

    this.showResults = false;


      this.sce = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.metaData.packageName);

      Scenario scenario = (Scenario) asset.content;
      if (scenario.fixtures.size() == 0) {
        scenario.fixtures.add(new ExecutionTrace());
      }

      if (!asset.isreadonly) {
View Full Code Here

    if (this.layout.getWidgetCount() == 2) {
      this.layout.remove(1);
    }


    final Scenario scenario = (Scenario) asset.content;
    DirtyableFlexTable editorLayout = new DirtyableFlexTable();
    editorLayout.clear();
    editorLayout.setWidth("100%");
    editorLayout.setStyleName("model-builder-Background");
//    this.layout.setWidget(1, 0, editorLayout);
    this.layout.add(editorLayout);
    ScenarioHelper hlp = new ScenarioHelper();
    List fixtures = hlp.lumpyMap(scenario.fixtures);


        int layoutRow = 1;
        ExecutionTrace previousEx = null;
        for (int i = 0; i < fixtures.size(); i++) {
      final Object f = fixtures.get(i);
      if (f instanceof ExecutionTrace) {
        previousEx = (ExecutionTrace) f;
        HorizontalPanel h = new HorizontalPanel();
        h.add(getNewExpectationButton(previousEx, scenario));
        h.add(new SmallLabel(constants.EXPECT()));
        editorLayout.setWidget(layoutRow, 0, h);

                final ExecutionTrace et = (ExecutionTrace) previousEx;
                Image del = new ImageButton("images/delete_item_small.gif", constants.DeleteItem(), new ClickListener() {
                    public void onClick(Widget w) {
                         if ( Window.confirm(constants.AreYouSureYouWantToRemoveThisItem()) ) {
                             scenario.removeExecutionTrace( et );
                             renderEditor();
                         }
                    }
                });
                h.add(del);
View Full Code Here

            RuleCoverageListener coverage = new RuleCoverageListener( expectedRules( bin ) );

            while ( it.hasNext() ) {
                RuleAsset asset = loadAsset( (AssetItem) it.next() );
                Scenario sc = (Scenario) asset.content;
                runScenario( item.getName(),
                             sc,
                             coverage );//runScenario(sc, res, workingMemory).scenario;

                int[] totals = sc.countFailuresTotal();
                resultSummaries.add( new ScenarioResultSummary( totals[0],
                                                                totals[1],
                                                                asset.metaData.name,
                                                                asset.metaData.description,
                                                                asset.uuid ) );
View Full Code Here

public class ScenarioContentHandler extends PlainTextContentHandler {

  @Override
  public void retrieveAssetContent(RuleAsset asset, PackageItem pkg,
      AssetItem item) throws SerializableException {
    Scenario sc = ScenarioXMLPersistence.getInstance().unmarshal(item.getContent());
    asset.content = sc;

  }
View Full Code Here

  }

  @Override
  public void storeAssetContent(RuleAsset asset, AssetItem repoAsset)
      throws SerializableException {
    Scenario sc = (Scenario) asset.content;
    repoAsset.updateContent(ScenarioXMLPersistence.getInstance().marshal(sc));
  }
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

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.