[jboss-svn-commits] JBL Code SVN: r35736 - in labs/jbossrules/trunk/drools-guvnor/src: main/java/org/drools/guvnor/client/rpc and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 26 09:19:24 EDT 2010
Author: Rikkola
Date: 2010-10-26 09:19:22 -0400 (Tue, 26 Oct 2010)
New Revision: 35736
Added:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/FiredRulesPanel.java
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ExecutionWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/TestRunnerWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/ScenarioRunResult.java
labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
Log:
[#GUVNOR-636] Problem with Guvnor 5.1.1, <save> frequently does not save...
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ExecutionWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ExecutionWidget.java 2010-10-26 12:16:03 UTC (rev 35735)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ExecutionWidget.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -27,13 +27,9 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
-import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox;
@@ -48,6 +44,7 @@
* To change this template use File | Settings | File Templates.
*/
public class ExecutionWidget extends Composite {
+
private Constants constants = ((Constants) GWT.create( Constants.class ));
private final ExecutionTrace executionTrace;
@@ -85,7 +82,7 @@
if ( showResults && isResultNotNullAndHaveRulesFired() ) {
VerticalPanel replacingLayout = new VerticalPanel();
- replacingLayout.add( getShowPanel() );
+ replacingLayout.add( new FiredRulesPanel( executionTrace ) );
replacingLayout.add( layout );
initWidget( replacingLayout );
} else {
@@ -97,31 +94,6 @@
return executionTrace.getExecutionTimeResult() != null && executionTrace.getNumberOfRulesFired() != null;
}
- private HorizontalPanel getShowPanel() {
- HTML rep = new HTML( "<i><small>" + Format.format( constants.property0RulesFiredIn1Ms(),
- executionTrace.getNumberOfRulesFired().toString(),
- executionTrace.getExecutionTimeResult().toString() ) + "</small></i>" );
-
- final HorizontalPanel horizontalPanel = new HorizontalPanel();
- horizontalPanel.add( rep );
-
- final Button show = new Button( constants.ShowRulesFired() );
- show.addClickHandler( new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- ListBox rules = new ListBox( true );
- for ( int i = 0; i < executionTrace.getRulesFired().length; i++ ) {
- rules.addItem( executionTrace.getRulesFired()[i] );
- }
- horizontalPanel.add( new SmallLabel( " :" + constants.RulesFired() ) );
- horizontalPanel.add( rules );
- show.setVisible( false );
- }
- } );
- horizontalPanel.add( show );
- return horizontalPanel;
- }
-
private boolean isScenarioSimulatedDateSet() {
return executionTrace.getScenarioSimulatedDate() != null;
}
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/FiredRulesPanel.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/FiredRulesPanel.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/FiredRulesPanel.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.guvnor.client.qa.testscenarios;
+
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.util.Format;
+import org.drools.ide.common.client.modeldriven.testing.ExecutionTrace;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.ListBox;
+
+/**
+ *
+ * @author rikkola
+ *
+ */
+public class FiredRulesPanel extends HorizontalPanel {
+
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
+
+ private final ExecutionTrace executionTrace;
+
+ public FiredRulesPanel(ExecutionTrace executionTrace) {
+ this.executionTrace = executionTrace;
+
+ add( createText() );
+ add( createShowButton() );
+ }
+
+ private HTML createText() {
+ return new HTML( "<i><small>" + Format.format( constants.property0RulesFiredIn1Ms(),
+ executionTrace.getNumberOfRulesFired().toString(),
+ executionTrace.getExecutionTimeResult().toString() ) + "</small></i>" );
+ }
+
+ private Button createShowButton() {
+ final Button show = new Button( constants.ShowRulesFired() );
+ show.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ ListBox rules = new ListBox( true );
+ for ( String ruleName : executionTrace.getRulesFired() ) {
+ rules.addItem( ruleName );
+ }
+ add( new SmallLabel( " :" + constants.RulesFired() ) );
+ add( rules );
+ show.setVisible( false );
+ }
+ } );
+
+ return show;
+ }
+}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java 2010-10-26 12:16:03 UTC (rev 35735)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,6 +25,7 @@
import org.drools.guvnor.client.messages.Constants;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
import org.drools.guvnor.client.qa.VerifyRulesFiredWidget;
+import org.drools.guvnor.client.rpc.MetaData;
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
@@ -39,12 +40,14 @@
import org.drools.ide.common.client.modeldriven.testing.VerifyRuleFired;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
@@ -60,13 +63,13 @@
private String[] availableRules;
protected final SuggestionCompletionEngine suggestionCompletionEngine;
- private ChangeListener ruleSelectionCL;
- final RuleAsset asset;
- private final Scenario scenario;
- final VerticalPanel layout;
- boolean showResults;
+ private ChangeHandler ruleSelectionCL;
+ private final RuleAsset asset;
+ private final VerticalPanel layout;
+ private boolean showResults;
private Constants constants = ((Constants) GWT.create( Constants.class ));
+ private HandlerRegistration availableRulesHandlerRegistration;
public ScenarioWidget(RuleAsset asset,
RuleViewer viewer) {
@@ -76,13 +79,12 @@
public ScenarioWidget(RuleAsset asset) {
this.asset = asset;
this.layout = new VerticalPanel();
- this.showResults = false;
+ this.setShowResults( false );
this.suggestionCompletionEngine = SuggestionCompletionCache.getInstance().getEngineFromCache( asset.metaData.packageName );
- scenario = (Scenario) asset.content;
- if ( scenario.fixtures.size() == 0 ) {
- scenario.fixtures.add( new ExecutionTrace() );
+ if ( getScenario().fixtures.size() == 0 ) {
+ getScenario().fixtures.add( new ExecutionTrace() );
}
if ( !asset.isreadonly ) {
@@ -113,7 +115,7 @@
this.layout.add( editorLayout );
ScenarioHelper scenarioHelper = new ScenarioHelper();
- List<Fixture> fixtures = scenarioHelper.lumpyMap( scenario.fixtures );
+ List<Fixture> fixtures = scenarioHelper.lumpyMap( getScenario().fixtures );
List<ExecutionTrace> listExecutionTrace = new ArrayList<ExecutionTrace>();
for ( int i = 0; i < fixtures.size(); i++ ) {
final Object fixture = fixtures.get( i );
@@ -123,16 +125,15 @@
}
int layoutRow = 1;
int executionTraceLine = 0;
- ExecutionTrace previousEx = null;
- for ( int i = 0; i < fixtures.size(); i++ ) {
- final Fixture fixture = fixtures.get( i );
+ ExecutionTrace previousExecutionTrace = null;
+ for ( final Fixture fixture : fixtures ) {
if ( fixture instanceof ExecutionTrace ) {
- previousEx = (ExecutionTrace) fixture;
+ ExecutionTrace currentExecutionTrace = (ExecutionTrace) fixture;
editorLayout.setWidget( layoutRow,
0,
new ExpectPanel( asset.metaData.packageName,
- previousEx,
- scenario,
+ currentExecutionTrace,
+ getScenario(),
this ) );
executionTraceLine++;
@@ -141,17 +142,19 @@
}
editorLayout.setWidget( layoutRow,
1,
- new ExecutionWidget( previousEx,
- showResults ) );
+ new ExecutionWidget( currentExecutionTrace,
+ isShowResults() ) );
editorLayout.getFlexCellFormatter().setHorizontalAlignment( layoutRow,
2,
HasHorizontalAlignment.ALIGN_LEFT );
- } else if (fixture instanceof FixturesMap) {
+ previousExecutionTrace = currentExecutionTrace;
+
+ } else if ( fixture instanceof FixturesMap ) {
editorLayout.setWidget( layoutRow,
0,
- new GivenLabelButton( previousEx,
- scenario,
+ new GivenLabelButton( previousExecutionTrace,
+ getScenario(),
listExecutionTrace.get( executionTraceLine ),
this ) );
@@ -164,19 +167,21 @@
executionTraceLine,
(FixturesMap) fixture ) );
}
- } else if (fixture instanceof CallFixtureMap) {
- editorLayout.setWidget(layoutRow, 0,
- new CallMethodLabelButton(previousEx, scenario,
- listExecutionTrace.get(executionTraceLine),
- this));
+ } else if ( fixture instanceof CallFixtureMap ) {
+ editorLayout.setWidget( layoutRow,
+ 0,
+ new CallMethodLabelButton( previousExecutionTrace,
+ getScenario(),
+ listExecutionTrace.get( executionTraceLine ),
+ this ) );
- layoutRow++;
- editorLayout.setWidget(
- layoutRow,
- 1,
- newCallMethodOnGivenPanel(listExecutionTrace,
- executionTraceLine, (CallFixtureMap) fixture));
- } else {
+ layoutRow++;
+ editorLayout.setWidget( layoutRow,
+ 1,
+ newCallMethodOnGivenPanel( listExecutionTrace,
+ executionTraceLine,
+ (CallFixtureMap) fixture ) );
+ } else {
FixtureList fixturesList = (FixtureList) fixture;
Fixture first = fixturesList.get( 0 );
if ( first instanceof VerifyFact ) {
@@ -185,15 +190,15 @@
1,
new VerifyFactsPanel( fixturesList,
listExecutionTrace.get( executionTraceLine ),
- scenario,
+ getScenario(),
this,
- showResults ) );
+ isShowResults() ) );
} else if ( first instanceof VerifyRuleFired ) {
editorLayout.setWidget( layoutRow,
1,
new VerifyRulesFiredWidget( fixturesList,
- scenario,
- showResults ) );
+ getScenario(),
+ isShowResults() ) );
}
}
@@ -203,7 +208,7 @@
//add more execution sections.
editorLayout.setWidget( layoutRow,
0,
- new AddExecuteButton( scenario,
+ new AddExecuteButton( getScenario(),
this ) );
layoutRow++;
@@ -214,7 +219,7 @@
//config section
editorLayout.setWidget( layoutRow,
1,
- new ConfigWidget( scenario,
+ new ConfigWidget( getScenario(),
asset.metaData.packageName,
this ) );
@@ -222,7 +227,7 @@
//global section
HorizontalPanel h = new HorizontalPanel();
- h.add( new GlobalButton( scenario,
+ h.add( new GlobalButton( getScenario(),
this ) );
h.add( new SmallLabel( constants.globals() ) );
editorLayout.setWidget( layoutRow,
@@ -231,9 +236,9 @@
editorLayout.setWidget( layoutRow,
1,
- new GlobalPanel( scenarioHelper.lumpyMapGlobals( scenario.globals ),
- scenario,
- previousEx,
+ new GlobalPanel( scenarioHelper.lumpyMapGlobals( getScenario().globals ),
+ getScenario(),
+ previousExecutionTrace,
this ) );
}
@@ -245,7 +250,7 @@
return new GivenPanel( listExecutionTrace,
executionTraceLine,
given,
- scenario,
+ getScenario(),
this );
} else {
@@ -253,21 +258,22 @@
}
}
- private Widget newCallMethodOnGivenPanel(
- List<ExecutionTrace> listExecutionTrace, int executionTraceLine,
- CallFixtureMap given) {
+ private Widget newCallMethodOnGivenPanel(List<ExecutionTrace> listExecutionTrace,
+ int executionTraceLine,
+ CallFixtureMap given) {
- if (given.size() > 0) {
- return new CallMethodOnGivenPanel(listExecutionTrace, executionTraceLine,
- given, scenario, this);
+ if ( given.size() > 0 ) {
+ return new CallMethodOnGivenPanel( listExecutionTrace,
+ executionTraceLine,
+ given,
+ getScenario(),
+ this );
- } else {
- return new HTML("<i><small>"
- + constants.AddInputDataAndExpectationsHere()
- + "</small></i>");
- }
- }
-
+ } else {
+ return new HTML( "<i><small>" + constants.AddInputDataAndExpectationsHere() + "</small></i>" );
+ }
+ }
+
public Widget getRuleSelectionWidget(final String packageName,
final RuleSelectionEvent selected) {
final HorizontalPanel horizontalPanel = new HorizontalPanel();
@@ -282,15 +288,17 @@
availableRulesBox.addItem( availableRules[i] );
}
availableRulesBox.setSelectedIndex( 0 );
- availableRulesBox.removeChangeListener( ruleSelectionCL );
- ruleSelectionCL = new ChangeListener() {
+ if ( availableRulesHandlerRegistration != null ) {
+ availableRulesHandlerRegistration.removeHandler();
+ }
+ ruleSelectionCL = new ChangeHandler() {
- public void onChange(Widget w) {
+ public void onChange(ChangeEvent event) {
ruleNameTextBox.setText( availableRulesBox.getItemText( availableRulesBox.getSelectedIndex() ) );
}
};
- availableRulesBox.addChangeListener( ruleSelectionCL );
+ availableRulesHandlerRegistration = availableRulesBox.addChangeHandler( ruleSelectionCL );
horizontalPanel.add( availableRulesBox );
} else {
@@ -319,13 +327,12 @@
for ( int i = 0; i < list.length; i++ ) {
availableRulesBox.addItem( list[i] );
}
- ruleSelectionCL = new ChangeListener() {
-
- public void onChange(Widget w) {
+ ruleSelectionCL = new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
ruleNameTextBox.setText( availableRulesBox.getItemText( availableRulesBox.getSelectedIndex() ) );
}
};
- availableRulesBox.addChangeListener( ruleSelectionCL );
+ availableRulesHandlerRegistration = availableRulesBox.addChangeHandler( ruleSelectionCL );
availableRulesBox.setSelectedIndex( 0 );
horizontalPanel.add( availableRulesBox );
horizontalPanel.remove( busy );
@@ -376,4 +383,24 @@
width,
percent );
}
+
+ void setShowResults(boolean showResults) {
+ this.showResults = showResults;
+ }
+
+ boolean isShowResults() {
+ return showResults;
+ }
+
+ public MetaData getMetaData() {
+ return asset.metaData;
+ }
+
+ public void setScenario(Scenario scenario) {
+ asset.content = scenario;
+ }
+
+ public Scenario getScenario() {
+ return (Scenario) asset.content;
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/TestRunnerWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/TestRunnerWidget.java 2010-10-26 12:16:03 UTC (rev 35735)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/TestRunnerWidget.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -16,23 +16,39 @@
package org.drools.guvnor.client.qa.testscenarios;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.*;
+import java.util.Iterator;
+import java.util.List;
+
import org.drools.guvnor.client.common.GenericCallback;
import org.drools.guvnor.client.common.LoadingPopup;
import org.drools.guvnor.client.common.SmallLabel;
import org.drools.guvnor.client.messages.Constants;
-import org.drools.guvnor.client.rpc.BuilderResult;
import org.drools.guvnor.client.rpc.BuilderResultLine;
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.ScenarioRunResult;
import org.drools.guvnor.client.rpc.SingleScenarioResult;
import org.drools.guvnor.client.util.Format;
-import org.drools.ide.common.client.modeldriven.testing.*;
+import org.drools.ide.common.client.modeldriven.testing.ExecutionTrace;
+import org.drools.ide.common.client.modeldriven.testing.Fixture;
+import org.drools.ide.common.client.modeldriven.testing.VerifyFact;
+import org.drools.ide.common.client.modeldriven.testing.VerifyField;
+import org.drools.ide.common.client.modeldriven.testing.VerifyRuleFired;
-import java.util.Iterator;
-import java.util.List;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ScrollPanel;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
/**
* Created by IntelliJ IDEA.
@@ -41,206 +57,256 @@
* Time: 19:27:09
* To change this template use File | Settings | File Templates.
*/
-public /**
- * Runs the test, plus shows a summary view of the results.
- */
+public/**
+* Runs the test, plus shows a summary view of the results.
+*/
class TestRunnerWidget extends Composite {
- FlexTable results = new FlexTable();
- //Grid layout = new Grid(2, 1);
- VerticalPanel layout = new VerticalPanel();
+ FlexTable results = new FlexTable();
+ VerticalPanel layout = new VerticalPanel();
- //private HorizontalPanel busy = new HorizontalPanel();
- private SimplePanel actions = new SimplePanel();
- private Constants constants = ((Constants) GWT.create(Constants.class));
+ private SimplePanel actions = new SimplePanel();
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
- public TestRunnerWidget(final ScenarioWidget parent, final String packageName) {
+ public TestRunnerWidget(final ScenarioWidget parent,
+ final String packageName) {
- final Button run = new Button(constants.RunScenario());
- run.setTitle(constants.RunScenarioTip());
- run.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- LoadingPopup.showMessage(constants.BuildingAndRunningScenario());
- RepositoryServiceFactory.getService().runScenario(parent.asset.metaData.packageName, (Scenario) parent.asset.content, new GenericCallback<SingleScenarioResult>() {
- public void onSuccess(SingleScenarioResult data) {
- LoadingPopup.close();
- layout.clear();
- layout.add(actions);
- layout.add(results);
- actions.setVisible(true);
- ScenarioRunResult result = data.result;
- if (result.errors != null) {
- showErrors(result.errors);
- } else {
- showResults(parent, data);
- }
- }
- });
- }
- });
+ final Button run = new Button( constants.RunScenario() );
+ run.setTitle( constants.RunScenarioTip() );
+ run.addClickHandler( new ClickHandler() {
- actions.add(run);
- layout.add(actions);
- initWidget(layout);
- }
+ public void onClick(ClickEvent event) {
+ LoadingPopup.showMessage( constants.BuildingAndRunningScenario() );
+ RepositoryServiceFactory.getService().runScenario( parent.getMetaData().packageName,
+ parent.getScenario(),
+ new GenericCallback<SingleScenarioResult>() {
+ public void onSuccess(SingleScenarioResult data) {
+ LoadingPopup.close();
+ layout.clear();
+ layout.add( actions );
+ layout.add( results );
+ actions.setVisible( true );
+ ScenarioRunResult result = data.result;
+ if ( result.getErrors() != null ) {
+ showErrors( result.getErrors() );
+ } else {
+ showResults( parent,
+ data );
+ }
+ }
+ } );
+ }
+ } );
+ actions.add( run );
+ layout.add( actions );
+ initWidget( layout );
+ }
- private void showErrors(BuilderResultLine[] rs) {
- results.clear();
- results.setVisible(true);
+ private void showErrors(BuilderResultLine[] rs) {
+ results.clear();
+ results.setVisible( true );
FlexTable errTable = new FlexTable();
errTable.setStyleName( "build-Results" );
for ( int i = 0; i < rs.length; i++ ) {
int row = i;
final BuilderResultLine res = rs[i];
- errTable.setWidget( row, 0, new Image("images/error.gif"));
- if( res.assetFormat.equals( "package" )) {
- errTable.setText( row, 1, constants.packageConfigurationProblem1() + res.message );
+ errTable.setWidget( row,
+ 0,
+ new Image( "images/error.gif" ) );
+ if ( res.assetFormat.equals( "package" ) ) {
+ errTable.setText( row,
+ 1,
+ constants.packageConfigurationProblem1() + res.message );
} else {
- errTable.setText( row, 1, "[" + res.assetName + "] " + res.message );
+ errTable.setText( row,
+ 1,
+ "[" + res.assetName + "] " + res.message );
}
}
- ScrollPanel scroll = new ScrollPanel(errTable);
+ ScrollPanel scroll = new ScrollPanel( errTable );
scroll.setWidth( "100%" );
- results.setWidget(0, 0, scroll);
+ results.setWidget( 0,
+ 0,
+ scroll );
- }
+ }
- private void showResults(final ScenarioWidget parent,
- final SingleScenarioResult data) {
- results.clear();
- results.setVisible(true);
+ private void showResults(final ScenarioWidget parent,
+ final SingleScenarioResult data) {
+ results.clear();
+ results.setVisible( true );
- parent.asset.content = data.result.scenario;
- parent.showResults = true;
- parent.renderEditor();
+ parent.setScenario( data.result.getScenario() );
- int failures = 0;
- int total = 0;
- VerticalPanel resultsDetail = new VerticalPanel();
+ parent.setShowResults( true );
+ parent.renderEditor();
+ int failures = 0;
+ int total = 0;
+ VerticalPanel resultsDetail = new VerticalPanel();
- for (Iterator iterator = data.result.scenario.fixtures.iterator(); iterator.hasNext();) {
- Fixture f = (Fixture) iterator.next();
- if (f instanceof VerifyRuleFired) {
+ for ( Iterator<Fixture> fixturesIterator = data.result.getScenario().fixtures.iterator(); fixturesIterator.hasNext(); ) {
+ Fixture fixture = fixturesIterator.next();
+ if ( fixture instanceof VerifyRuleFired ) {
- VerifyRuleFired vr = (VerifyRuleFired)f;
- HorizontalPanel h = new HorizontalPanel();
- if (!vr.successResult.booleanValue()) {
- h.add(new Image("images/warning.gif"));
- failures++;
- } else {
- h.add(new Image("images/test_passed.png"));
- }
- h.add(new SmallLabel(vr.explanation));
- resultsDetail.add(h);
- total++;
- } else if (f instanceof VerifyFact) {
- VerifyFact vf = (VerifyFact)f;
- for (Iterator it = vf.fieldValues.iterator(); it.hasNext();) {
- total++;
- VerifyField vfl = (VerifyField) it.next();
- HorizontalPanel h = new HorizontalPanel();
- if (!vfl.successResult.booleanValue()) {
- h.add(new Image("images/warning.gif"));
- failures++;
- } else {
- h.add(new Image("images/test_passed.png"));
- }
- h.add(new SmallLabel(vfl.explanation));
- resultsDetail.add(h);
- }
+ VerifyRuleFired verifyRuleFired = (VerifyRuleFired) fixture;
+ HorizontalPanel panel = new HorizontalPanel();
+ if ( !verifyRuleFired.successResult.booleanValue() ) {
+ panel.add( new Image( "images/warning.gif" ) );
+ failures++;
+ } else {
+ panel.add( new Image( "images/test_passed.png" ) );
+ }
+ panel.add( new SmallLabel( verifyRuleFired.explanation ) );
+ resultsDetail.add( panel );
+ total++;
+ } else if ( fixture instanceof VerifyFact ) {
+ VerifyFact verifyFact = (VerifyFact) fixture;
+ for ( Iterator<VerifyField> fieldIterator = verifyFact.fieldValues.iterator(); fieldIterator.hasNext(); ) {
+ total++;
+ VerifyField verifyField = fieldIterator.next();
+ HorizontalPanel panel = new HorizontalPanel();
+ if ( !verifyField.successResult.booleanValue() ) {
+ panel.add( new Image( "images/warning.gif" ) );
+ failures++;
+ } else {
+ panel.add( new Image( "images/test_passed.png" ) );
+ }
+ panel.add( new SmallLabel( verifyField.explanation ) );
+ resultsDetail.add( panel );
+ }
+ } else if ( fixture instanceof ExecutionTrace ) {
+ ExecutionTrace ex = (ExecutionTrace) fixture;
+ if ( ex.getNumberOfRulesFired() == data.result.getScenario().maxRuleFirings ) {
+ Window.alert( Format.format( constants.MaxRuleFiringsReachedWarning(),
+ data.result.getScenario().maxRuleFirings ) );
+ }
+ }
- } else if (f instanceof ExecutionTrace) {
- ExecutionTrace ex = (ExecutionTrace) f;
- if (ex.getNumberOfRulesFired() == data.result.scenario.maxRuleFirings) {
- Window.alert(Format.format(constants.MaxRuleFiringsReachedWarning(), data.result.scenario.maxRuleFirings));
- }
- }
+ }
+ results.setWidget( 0,
+ 0,
+ new SmallLabel( constants.Results() ) );
+ results.getFlexCellFormatter().setHorizontalAlignment( 0,
+ 0,
+ HasHorizontalAlignment.ALIGN_RIGHT );
+ if ( failures > 0 ) {
+ results.setWidget( 0,
+ 1,
+ ScenarioWidget.getBar( "#CC0000",
+ 150,
+ failures,
+ total ) );
+ } else {
+ results.setWidget( 0,
+ 1,
+ ScenarioWidget.getBar( "GREEN",
+ 150,
+ failures,
+ total ) );
+ }
- }
+ results.setWidget( 1,
+ 0,
+ new SmallLabel( constants.SummaryColon() ) );
+ results.getFlexCellFormatter().setHorizontalAlignment( 1,
+ 0,
+ HasHorizontalAlignment.ALIGN_RIGHT );
+ results.setWidget( 1,
+ 1,
+ resultsDetail );
+ results.setWidget( 2,
+ 0,
+ new SmallLabel( constants.AuditLogColon() ) );
- results.setWidget(0, 0, new SmallLabel(constants.Results()));
- results.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
- if (failures > 0) {
- results.setWidget(0, 1, ScenarioWidget.getBar("#CC0000" , 150, failures, total));
- } else {
- results.setWidget(0, 1, ScenarioWidget.getBar("GREEN" , 150, failures, total));
- }
+ final Button showExp = new Button( constants.ShowEventsButton() );
+ results.setWidget( 2,
+ 1,
+ showExp );
+ showExp.addClickHandler( new ClickHandler() {
- results.setWidget(1, 0, new SmallLabel(constants.SummaryColon()));
- results.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
- results.setWidget(1, 1, resultsDetail);
- results.setWidget(2, 0, new SmallLabel(constants.AuditLogColon()));
+ public void onClick(ClickEvent event) {
+ showExp.setVisible( false );
+ results.setWidget( 2,
+ 1,
+ doAuditView( data.auditLog ) );
+ }
+ } );
- final Button showExp = new Button(constants.ShowEventsButton());
- results.setWidget(2, 1, showExp);
- showExp.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- showExp.setVisible(false);
- results.setWidget(2, 1, doAuditView(data.auditLog));
- }
- });
+ }
+ private Widget doAuditView(List<String[]> auditLog) {
+ VerticalPanel vp = new VerticalPanel();
+ vp.add( new HTML( "<hr/>" ) );
+ FlexTable g = new FlexTable();
+ int row = 0;
+ boolean firing = false;
+ for ( int i = 0; i < auditLog.size(); i++ ) {
+ String[] lg = auditLog.get( i );
+ int id = Integer.parseInt( lg[0] );
+ if ( id <= 7 ) {
+ if ( id <= 3 ) {
+ if ( !firing ) {
+ g.setWidget( row,
+ 0,
+ new Image( "images/audit_events/" + lg[0] + ".gif" ) );
+ g.setWidget( row,
+ 1,
+ new SmallLabel( lg[1] ) );
+ } else {
+ g.setWidget( row,
+ 1,
+ hz( new Image( "images/audit_events/" + lg[0] + ".gif" ),
+ new SmallLabel( lg[1] ) ) );
+ }
+ row++;
+ } else if ( id == 6 ) {
+ firing = true;
+ g.setWidget( row,
+ 0,
+ new Image( "images/audit_events/" + lg[0] + ".gif" ) );
+ g.setWidget( row,
+ 1,
+ new SmallLabel( "<b>" + lg[1] + "</b>" ) );
+ row++;
+ } else if ( id == 7 ) {
+ firing = false;
+ } else {
+ g.setWidget( row,
+ 0,
+ new Image( "images/audit_events/" + lg[0] + ".gif" ) );
+ g.setWidget( row,
+ 1,
+ new SmallLabel( "<font color='grey'>" + lg[1] + "</font>" ) );
+ row++;
+ }
+ } else {
+ g.setWidget( row,
+ 0,
+ new Image( "images/audit_events/misc_event.gif" ) );
+ g.setWidget( row,
+ 1,
+ new SmallLabel( "<font color='grey'>" + lg[1] + "</font>" ) );
+ row++;
+ }
+ }
+ vp.add( g );
+ vp.add( new HTML( "<hr/>" ) );
+ return vp;
+ }
- }
-
-
-
- private Widget doAuditView(List<String[]> auditLog) {
- VerticalPanel vp = new VerticalPanel();
- vp.add(new HTML("<hr/>"));
- FlexTable g = new FlexTable();
- String indent = "";
- int row = 0;
- boolean firing = false;
- for (int i = 0; i < auditLog.size(); i++) {
- String[] lg = auditLog.get(i);
-
- int id = Integer.parseInt(lg[0]);
- if (id <= 7) {
- if (id <= 3) {
- if (!firing) {
- g.setWidget(row, 0, new Image("images/audit_events/" + lg[0] + ".gif"));
- g.setWidget(row, 1, new SmallLabel(lg[1]));
- } else {
- g.setWidget(row, 1, hz(new Image("images/audit_events/" + lg[0] + ".gif"), new SmallLabel(lg[1])));
- }
- row++;
- } else if (id == 6) {
- firing = true;
- g.setWidget(row, 0, new Image("images/audit_events/" + lg[0] + ".gif"));
- g.setWidget(row, 1, new SmallLabel("<b>" + lg[1] + "</b>"));
- row++;
- } else if (id == 7) {
- firing = false;
- } else {
- g.setWidget(row, 0, new Image("images/audit_events/" + lg[0] + ".gif"));
- g.setWidget(row, 1, new SmallLabel("<font color='grey'>" + lg[1] + "</font>"));
- row++;
- }
- } else {
- g.setWidget(row, 0, new Image("images/audit_events/misc_event.gif"));
- g.setWidget(row, 1, new SmallLabel("<font color='grey'>" + lg[1] + "</font>"));
- row++;
- }
- }
- vp.add(g);
- vp.add(new HTML("<hr/>"));
- return vp;
- }
-
-
- private Widget hz(Image image, SmallLabel smallLabel) {
- HorizontalPanel h = new HorizontalPanel();
- h.add(image);
- h.add(smallLabel);
- return h;
- }
+ private Widget hz(Image image,
+ SmallLabel smallLabel) {
+ HorizontalPanel h = new HorizontalPanel();
+ h.add( image );
+ h.add( smallLabel );
+ return h;
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/ScenarioRunResult.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/ScenarioRunResult.java 2010-10-26 12:16:03 UTC (rev 35735)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/ScenarioRunResult.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,17 +25,29 @@
* It will either be a list of rule compiler errors (should it have to compile), or the scenario run results.
* @author Michael Neale
*/
-public class ScenarioRunResult implements IsSerializable {
+public class ScenarioRunResult
+ implements
+ IsSerializable {
- public ScenarioRunResult() {}
+ private BuilderResultLine[] errors;
+ private Scenario scenario;
+ public ScenarioRunResult() {
+ }
- public BuilderResultLine[] errors;
- public Scenario scenario;
- public ScenarioRunResult(BuilderResultLine[] errors, Scenario scenario) {
+ public ScenarioRunResult(BuilderResultLine[] errors,
+ Scenario scenario) {
- this.errors = errors;
- this.scenario = scenario;
- }
+ this.errors = errors;
+ this.scenario = scenario;
+ }
+ public Scenario getScenario() {
+ return scenario;
+ }
+
+ public BuilderResultLine[] getErrors() {
+ return errors;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-10-26 12:16:03 UTC (rev 35735)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-10-26 13:19:22 UTC (rev 35736)
@@ -2986,16 +2986,16 @@
ScenarioRunResult res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
@@ -3003,8 +3003,8 @@
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
@@ -3019,10 +3019,10 @@
repo.save();
res = impl.runScenario( pkg.getName(),
sc ).result;
- assertNotNull( res.errors );
- assertNull( res.scenario );
+ assertNotNull( res.getErrors() );
+ assertNull( res.getScenario() );
- assertTrue( res.errors.length > 0 );
+ assertTrue( res.getErrors().length > 0 );
impl.createCategory( "/",
"sc",
@@ -3101,8 +3101,8 @@
ScenarioRunResult res = res_.result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
@@ -3268,16 +3268,16 @@
ScenarioRunResult res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
@@ -3286,8 +3286,8 @@
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vf.wasSuccessful() );
assertTrue( vr.wasSuccessful() );
@@ -3336,15 +3336,15 @@
fail( "Probably failed when loading a source file instead of class file. " + e );
}
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vr.wasSuccessful() );
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vr.wasSuccessful() );
impl.ruleBaseCache.clear();
@@ -3352,8 +3352,8 @@
res = impl.runScenario( pkg.getName(),
sc ).result;
assertEquals( null,
- res.errors );
- assertNotNull( res.scenario );
+ res.getErrors() );
+ assertNotNull( res.getScenario() );
assertTrue( vr.wasSuccessful() );
}
More information about the jboss-svn-commits
mailing list