Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DROOLS-4636] Update Scenario Cheatsheet to mention MVEL and Background #1277

Merged
merged 9 commits into from
Jan 22, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public interface ScenarioSimulationEditorConstants

String ruleCheatSheet22();

String ruleCheatSheet23();

String dmnCheatSheet1();

String dmnCheatSheet2();
Expand Down Expand Up @@ -357,4 +359,8 @@ public interface ScenarioSimulationEditorConstants
String testToolObjectSelectionTooltip();

String testToolClearSelection();

String ruleCheatSheetBackground();

String dmnCheatSheetBackground();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<div id="ruleCheatSheet">
<p id="ruleCheatSheetParagraph1"></p>
<p id="ruleCheatSheetParagraph2"></p>
<p id="ruleCheatSheetParagraphBackground"></p>
<p id="ruleCheatSheetParagraph3"></p>
<p id="ruleCheatSheetParagraph4"></p>
<ul>
Expand All @@ -31,6 +32,7 @@
<li id="ruleCheatSheetList4"></li>
<li id="ruleCheatSheetList5"></li>
<li id="ruleCheatSheetList6"></li>
<li id="ruleCheatSheetList7"></li>
</ul>
<p id="ruleCheatSheetParagraph5"></p>
<ul id="ruleCheatSheetExampleExpressions">
Expand All @@ -39,6 +41,7 @@
<div id="dmnCheatSheet">
<p id="dmnCheatSheetParagraph1"></p>
<p id="dmnCheatSheetParagraph2"></p>
<p id="dmnCheatSheetParagraphBackground"></p>
<p id="dmnCheatSheetParagraph3"></p>
<p id="dmnCheatSheetParagraph4"></p>
<p id="dmnCheatSheetParagraph5"></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class CheatSheetViewImpl
@DataField("ruleCheatSheetParagraph4")
protected ParagraphElement ruleCheatSheetParagraph4 = Document.get().createPElement();

@DataField("ruleCheatSheetParagraphBackground")
protected ParagraphElement ruleCheatSheetParagraphBackground = Document.get().createPElement();

@DataField("ruleCheatSheetList1")
protected LIElement ruleCheatSheetList1 = Document.get().createLIElement();

Expand All @@ -70,6 +73,9 @@ public class CheatSheetViewImpl
@DataField("ruleCheatSheetList6")
protected LIElement ruleCheatSheetList6 = Document.get().createLIElement();

@DataField("ruleCheatSheetList7")
protected LIElement ruleCheatSheetList7 = Document.get().createLIElement();

@DataField("ruleCheatSheetParagraph5")
protected ParagraphElement ruleCheatSheetParagraph5 = Document.get().createPElement();

Expand All @@ -94,6 +100,9 @@ public class CheatSheetViewImpl
@DataField("dmnCheatSheetParagraph5")
protected ParagraphElement dmnCheatSheetParagraph5 = Document.get().createPElement();

@DataField("dmnCheatSheetParagraphBackground")
protected ParagraphElement dmnCheatSheetParagraphBackground = Document.get().createPElement();

@DataField("dmnCheatSheetList1")
protected LIElement dmnCheatSheetList1 = Document.get().createLIElement();

Expand Down Expand Up @@ -137,6 +146,7 @@ public void setRuleCheatSheetContent() {
ruleCheatSheetParagraph2.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet2() + "<b>" + " " + ScenarioSimulationEditorConstants.INSTANCE.testEditor() + " " + "</b>"
+ ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet3() + " <b>" + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet4() + " </b>"
+ ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet5());
ruleCheatSheetParagraphBackground.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheetBackground());
ruleCheatSheetParagraph3.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet6());
ruleCheatSheetParagraph4.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet7());
ruleCheatSheetList1.setInnerHTML("<tt>=</tt>" + " " + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet8());
Expand All @@ -148,6 +158,7 @@ public void setRuleCheatSheetContent() {
+ " " + "<b>" + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet17() + "</b>" + " " + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet18());
ruleCheatSheetList6.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet19() + " " + "<tt>=</tt>, <tt>[]</tt>, " + ScenarioSimulationEditorConstants.INSTANCE.or() +
" " + "<tt>;</tt>. " + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet20() + " " + "<tt>null</tt>. " + ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet21());
ruleCheatSheetList7.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet23());
ruleCheatSheetParagraph5.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.ruleCheatSheet22());
ruleCheatSheetExampleExpressions.setInnerHTML("<li><tt>&lt; 1</tt></li>" +
"<li><tt>&lt; 1; ! [-1, 0]</tt></li>" +
Expand All @@ -165,6 +176,7 @@ public void setDMNCheatSheetContent() {
+ ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet3());
dmnCheatSheetParagraph3.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet4());
dmnCheatSheetParagraph4.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet5());
dmnCheatSheetParagraphBackground.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheetBackground());
dmnCheatSheetParagraph5.setInnerHTML(ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet6());
dmnCheatSheetList1.setInnerHTML("<i>" + ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet7() + " " + "</i>" + ScenarioSimulationEditorConstants.INSTANCE.and()
+ " " + "<i>" + ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet8() + "</i>" + " " + ScenarioSimulationEditorConstants.INSTANCE.dmnCheatSheet9() + " "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,6 @@ validationSucceed=Validation Succeed

backgroundTabTitle=Background
backgroundErrorNotification=There are errors in Background data, please have a look
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that we shell mention all of the limitation for expressions?
Bcs we are obviosly do not mention that if you will /0 the expression will fall, why should we mention about the return type? Just my feeling of the cheat sheet idea. I would like to only mention a key words.
# specifies expression you can use to invoke Java code.
actualValue specifies parameter for assertion in EXPECT.
But if you have other ideas...

If you really want to leave it here a shorten version of it as well:
Return type of the expression in GIVEN section should be the same as type of the column.
Return type of the expression in EXPECT section should be boolean assertion result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the additional information but I think it could be useful to have them here. I cannot user your suggested version because in EXPECT expression can return the same type (and in this case it will be verified as == to the actualValue) or a boolean so I mentioned both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what about using /expression? Coz we are no need to put # before the expression for those column.

ruleCheatSheet23=To specify a MVEL expression (or invoke a Java method) just put # at the beginning of the expression. In GIVEN section, return type of the expression has to be the same one of type of the column. In EXPECT section the type could also just a boolean with the result of the assertion and you can use actualValue identifier to access value to check.
ruleCheatSheetBackground=If the same GIVEN data is shared by multiple test scenarios, you can use the Background tab to define them once. You can create a column in Background in the same way of Model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it end with '.'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

dmnCheatSheetBackground=If the same GIVEN data is shared by multiple test scenarios, you can use the Background tab to define them once. You can create a column in Background in the same way of Model.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dmnCheatSheetBackground and ruleCheatSheetBackground are the same cannot we have only one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielezonca I agree with @dupliaka, I suggest to define a separate method (eg. setCommonCheatSheetContent()) where shared descriptions are set in one single point and with a single property definition, in order to avoid text duplication.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the duplication (commonCheatSheetBackground) but I prefer not to refactor the whole method to create a setCommonCheatSheetContent because the structure of the HTML is different. To do that we should refactor the whole panel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also since we discussed it with you @danielezonca the dmn and drl bkg are not the same;
So drl can use it as a batch update but dmn can not and dmn would take only last record of it