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

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


                listExecutionTrace.add((ExecutionTrace) f);
            }
        }
        int layoutRow = 1;
        int executionTraceLine = 0;
        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);
                executionTraceLine++;
                if (executionTraceLine >= listExecutionTrace.size()) {
                    executionTraceLine = listExecutionTrace.size() - 1;
                }
                editorLayout.setWidget(layoutRow, 1, new ExecutionWidget(previousEx, showResults));
                //layout.setWidget(layoutRow, 2, getNewExpectationButton(previousEx, scenario, availableRules));
                editorLayout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 2, HasHorizontalAlignment.ALIGN_LEFT);

            } else if (f instanceof Map) {
                HorizontalPanel h = new HorizontalPanel();
                h.add(getNewDataButton(previousEx, scenario, listExecutionTrace.get(executionTraceLine)));
                h.add(new SmallLabel(constants.GIVEN()));


                editorLayout.setWidget(layoutRow, 0, h);

                layoutRow++;
                Map given = (Map) f;
                VerticalPanel vert = new VerticalPanel();
                for (Iterator iterator = given.entrySet().iterator(); iterator.hasNext();) {
                    Map.Entry e = (Map.Entry) iterator.next();
                    List itemList = (List) given.get(e.getKey());
                    if (e.getKey().equals(ScenarioHelper.RETRACT_KEY)) {
                        vert.add(new RetractWidget(itemList,
                                scenario));
                    } else if (e.getKey().equals(ScenarioHelper.ACTIVATE_RULE_FLOW_GROUP)) {
                        vert.add(new ActivateRuleFlowWidget(itemList,
                                scenario));
                    } else {
                        vert.add(new DataInputWidget((String) e.getKey(),
                                itemList,
                                false,
                                scenario,
                                sce,
                                this,
                                listExecutionTrace.get(executionTraceLine)));
                    }
                }


                if (given.size() > 0) {
                    editorLayout.setWidget(layoutRow, 1, vert);
                } else {
                    editorLayout.setWidget(layoutRow, 1, new HTML("<i><small>" + constants.AddInputDataAndExpectationsHere() + "</small></i>"));
                }
            } else {
                List l = (List) f;
                Fixture first = (Fixture) l.get(0);
                if (first instanceof VerifyFact) {
                    doVerifyFacts(l,
                            editorLayout,
                            layoutRow,
                            scenario,
                            listExecutionTrace.get(executionTraceLine));
                } else if (first instanceof VerifyRuleFired) {
                    editorLayout.setWidget(layoutRow,
                            1,
                            new VerifyRulesFiredWidget(l,
                            scenario,
                            showResults));
                }

            }
            layoutRow++;
        }

        //add more execution sections.
        Button addExecute = new Button(constants.MoreDotDot());
        addExecute.setTitle(constants.AddAnotherSectionOfDataAndExpectations());
        addExecute.addClickListener(new ClickListener() {

            public void onClick(Widget w) {
                scenario.fixtures.add(new ExecutionTrace());
                renderEditor();
            }
        });
        editorLayout.setWidget(layoutRow, 0, addExecute);
        //layout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 1, HasHorizontalAlignment.ALIGN_CENTER);
View Full Code Here


        FactData person = new FactData();
        person.setName( "p" );
        person.setType( "Person" );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "MyGoodRule",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );
View Full Code Here

                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "p" );
        vf.getFieldValues().add( new VerifyField( "name",
                                                  "michael",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        AssetItem scenario1 = pkg.addAsset( "scen1",
                                            "" );
        scenario1.updateFormat( AssetFormats.TEST_SCENARIO );
        scenario1.updateContent( ScenarioXMLPersistence.getInstance().marshal( sc ) );
        scenario1.checkin( "" );

        //now the bad scenario
        sc = new Scenario();
        person = new FactData();
        person.setName( "p" );
        person.setType( "Person" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
                                  1,
                                  null );
        sc.getFixtures().add( vr );
View Full Code Here

                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "p" );
        vf.getFieldValues().add( new VerifyField( "name",
                                                  "michael",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        FactData cheese = new FactData();
        cheese.setName( "cheese" );
        cheese.setType( "Cheese" );
        cheese.getFieldData().add( new FieldData( "price",
                                                  "42" ) );
        sc.getGlobals().add( cheese );

        ScenarioRunResult res = repositoryPackageService.runScenario( pkg.getName(),
                                                                      sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        res = repositoryPackageService.runScenario( pkg.getName(),
                                                    sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        RuleBaseCache.getInstance().clearCache();
        res = repositoryPackageService.runScenario( pkg.getName(),
                                                    sc ).result;
        assertNull( res.getErrors() );
        assertNotNull( res.getScenario() );
        assertTrue( vf.wasSuccessful() );
        assertTrue( vr.wasSuccessful() );

        //BuilderResult[] results = impl.buildPackage(pkg.getUUID(), null, true);
        //assertNull(results);

        rule1.updateContent( "Junk" );
        rule1.checkin( "" );

        RuleBaseCache.getInstance().clearCache();
        pkg.updateBinaryUpToDate( false );
        repo.save();
        res = repositoryPackageService.runScenario( pkg.getName(),
                                                    sc ).result;
        assertNotNull( res.getErrors() );
        assertNull( res.getScenario() );

        assertTrue( res.getErrors().size() > 0 );

        repositoryCategoryService.createCategory( "/",
                                                  "sc",
                                                  "" );

        String scenarioId = impl.createNewRule( "sc1",
                                                "s",
                                                "sc",
                                                pkg.getName(),
                                                AssetFormats.TEST_SCENARIO );
        RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
        RuleAsset asset = repositoryAssetService.loadRuleAsset( scenarioId );
        assertNotNull( asset.getContent() );
        assertTrue( asset.getContent() instanceof Scenario );

        Scenario sc_ = (Scenario) asset.getContent();
        sc_.getFixtures().add( new ExecutionTrace() );
        repositoryAssetService.checkinVersion( asset );
        asset = repositoryAssetService.loadRuleAsset( scenarioId );
        assertNotNull( asset.getContent() );
        assertTrue( asset.getContent() instanceof Scenario );
        sc_ = (Scenario) asset.getContent();
View Full Code Here

                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "mic" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );
View Full Code Here

                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "p" );
        vf.getFieldValues().add( new VerifyField( "name",
                                                  "michael",
                                                  "==" ) );
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        AssetItem scenario1 = pkg.addAsset( "scen1",
                                            "" );
        scenario1.updateFormat( AssetFormats.TEST_SCENARIO );
        scenario1.updateContent( ScenarioXMLPersistence.getInstance().marshal( sc ) );
        scenario1.checkin( "" );

        //now the bad scenario
        sc = new Scenario();
        person = new FactData();
        person.setName( "p" );
        person.setType( "Wang" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        vr = new VerifyRuleFired( "rule2",
                                  1,
                                  null );
        sc.getFixtures().add( vr );
View Full Code Here

        person.setType( "Board" );
        person.getFieldData().add( new FieldData( "cost",
                                                  "42" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "MyGoodRule",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );
View Full Code Here

        setTitle( constants.AddAnotherSectionOfDataAndExpectations() );

        addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                scenario.fixtures.add( new ExecutionTrace() );
                parent.renderEditor();
            }
        } );
    }
View Full Code Here

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

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

        if ( !asset.isreadonly ) {
            layout.add( new TestRunnerWidget( this,
                                              asset.metaData.packageName ) );
View Full Code Here

                listExecutionTrace.add( (ExecutionTrace) fixture );
            }
        }
        int layoutRow = 1;
        int executionTraceLine = 0;
        ExecutionTrace previousEx = null;
        for ( int i = 0; i < fixtures.size(); i++ ) {
            final Fixture fixture = fixtures.get( i );
            if ( fixture instanceof ExecutionTrace ) {
                previousEx = (ExecutionTrace) fixture;
                editorLayout.setWidget( layoutRow,
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.testing.ExecutionTrace

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.