Skip to content

Commit 9d7236a

Browse files
committed
DSL cleanup
1 parent 4878c8c commit 9d7236a

File tree

3 files changed

+50
-82
lines changed

3 files changed

+50
-82
lines changed

.sbtopts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-J-XX:MaxMetaspaceSize=1024M
22
-J-Dsbt.sourcemode=true
33
-J-Djansi.passthrough=true
4+
-J-Xshare:off

build.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ Compile / packageBin / mappings ++= Seq(
7171
)
7272

7373
Test / parallelExecution := false
74+
75+
Test / testOptions += Tests.Argument("-oF")

src/test/scala/gwen/web/eval/WebEngineTest.scala

+47-82
Original file line numberDiff line numberDiff line change
@@ -966,18 +966,14 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before
966966
verify(mockTopScope, times(3)).set("<attribute>", "value", false)
967967
}
968968

969-
"""my <name> property <is|will be> "<value>"""" should "evaluate" in {
970-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
971-
evaluate(s"""my gwen.property-$i property $x "value-$i"""")
972-
Settings.get(s"gwen.property-$i") should be (s"value-$i")
973-
}
969+
"""my <name> property is "<value>"""" should "evaluate" in {
970+
evaluate(s"""my gwen.property-0 property is "value-0"""")
971+
Settings.get(s"gwen.property-0") should be (s"value-0")
974972
}
975973

976-
"""my <name> setting <is|will be> "<value>"""" should "evaluate" in {
977-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
978-
evaluate(s"""my gwen.setting-$i setting $x "value-$i"""")
979-
Settings.get(s"gwen.setting-$i") should be (s"value-$i")
980-
}
974+
"""my <name> setting is "<value>"""" should "evaluate" in {
975+
evaluate(s"""my gwen.setting-0 setting is "value-0"""")
976+
Settings.get(s"gwen.setting-0") should be (s"value-0")
981977
}
982978

983979
"I reset my <name> property" should "evaluate" in {
@@ -990,55 +986,43 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before
990986
Settings.getOpt(s"gwen.web") should be (None)
991987
}
992988

993-
"""<attribute> <is|will> be defined by javascript "<expression>"""" should "evaluate" in {
989+
"""<attribute> is defined by javascript "<expression>"""" should "evaluate" in {
994990
doReturn(mockTopScope).when(envState).topScope
995-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
996-
evaluate(s"""attribute-$i $x defined by javascript "expression-$i"""")
997-
verify(mockTopScope).set(s"attribute-$i/javascript", s"expression-$i", false)
998-
}
991+
evaluate(s"""attribute-0 is defined by javascript "expression-0"""")
992+
verify(mockTopScope).set(s"attribute-0/javascript", s"expression-0", false)
999993
}
1000994

1001-
"""<attribute> <is|will> be defined by property "<name>"""" should "evaluate" in {
1002-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1003-
withSetting(s"name-$i", s"$i") {
1004-
evaluate(s"""attribute-$i $x defined by property "name-$i"""")
1005-
verify(mockTopScope).set(s"attribute-$i", s"$i", false)
1006-
}
995+
"""<attribute> is defined by property "<name>"""" should "evaluate" in {
996+
withSetting(s"name-0", "0") {
997+
evaluate(s"""attribute-0 is defined by property "name-0"""")
998+
verify(mockTopScope).set(s"attribute-0", "0", false)
1007999
}
10081000
}
10091001

1010-
"""<attribute> <is|will> be defined by setting "<name>"""" should "evaluate" in {
1011-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1012-
withSetting(s"name-$i", s"$i") {
1013-
evaluate(s"""attribute-$i $x defined by setting "name-$i"""")
1014-
verify(mockTopScope).set(s"attribute-$i", s"$i", false)
1015-
}
1002+
"""<attribute> is defined by setting "<name>"""" should "evaluate" in {
1003+
withSetting(s"name-0", "0") {
1004+
evaluate(s"""attribute-0 is defined by setting "name-0"""")
1005+
verify(mockTopScope).set(s"attribute-0", "0", false)
10161006
}
10171007
}
10181008

1019-
"""<attribute> <is|will> be defined by system process "<process>"""" should "evaluate" in {
1009+
"""<attribute> is defined by system process "<process>"""" should "evaluate" in {
10201010
doReturn(mockTopScope).when(envState).topScope
1021-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1022-
evaluate(s"""attribute-$i $x defined by system process "process-$i"""")
1023-
verify(mockTopScope).set(s"attribute-$i/sysproc", s"process-$i", false)
1024-
}
1011+
evaluate(s"""attribute-0 is defined by system process "process-0"""")
1012+
verify(mockTopScope).set(s"attribute-0/sysproc", s"process-0", false)
10251013
}
10261014

1027-
"""<attribute> <is|will> be defined by system process "<process>" delimited by "<delimiter>"""" should "evaluate" in {
1015+
"""<attribute> is defined by system process "<process>" delimited by "<delimiter>"""" should "evaluate" in {
10281016
doReturn(mockTopScope).when(envState).topScope
1029-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1030-
evaluate(s"""attribute-$i $x defined by system process "process-$i" delimited by ","""")
1031-
verify(mockTopScope).set(s"attribute-$i/sysproc", s"process-$i", false)
1032-
verify(mockTopScope).set(s"attribute-$i/delimiter", s",", false)
1033-
}
1017+
evaluate(s"""attribute-0 is defined by system process "process-0" delimited by ","""")
1018+
verify(mockTopScope).set(s"attribute-0/sysproc", s"process-0", false)
1019+
verify(mockTopScope).set(s"attribute-0/delimiter", s",", false)
10341020
}
10351021

1036-
"""<attribute> <is|will> be defined by file "<filepath>"""" should "evaluate" in {
1022+
"""<attribute> is defined by file "<filepath>"""" should "evaluate" in {
10371023
doReturn(mockTopScope).when(envState).topScope
1038-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1039-
evaluate(s"""attribute-$i $x defined by file "filepath-$i"""")
1040-
verify(mockTopScope).set(s"attribute-$i/file", s"filepath-$i", false)
1041-
}
1024+
evaluate(s"""attribute-0 is defined by file "filepath-0"""")
1025+
verify(mockTopScope).set(s"attribute-0/file", s"filepath-0", false)
10421026
}
10431027

10441028
"""<attribute> is defined by the <text|node|nodeset> in <reference> by xpath "<expression>"""" should "evaluate" in {
@@ -1048,42 +1032,27 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before
10481032
verify(mockTopScope).set("<attribute>/xpath/source", s"<reference-$i>", false)
10491033
verify(mockTopScope).set("<attribute>/xpath/targetType", x, false)
10501034
verify(mockTopScope).set("<attribute>/xpath/expression", s"<expression-$i>", false)
1035+
reset(mockTopScope)
10511036
}
10521037
}
10531038

1054-
"""<attribute> will be defined by the <text|node|nodeset> in <reference> by xpath "<expression>"""" should "evaluate" in {
1055-
doReturn(mockTopScope).when(envState).topScope
1056-
List("text", "node", "nodeset").zipWithIndex.foreach { case (x, i) =>
1057-
evaluate(s"""<attribute> will be defined by the $x in <reference-$i> by xpath "<expression-$i>"""")
1058-
verify(mockTopScope).set("<attribute>/xpath/source", s"<reference-$i>", false)
1059-
verify(mockTopScope).set("<attribute>/xpath/targetType", x, false)
1060-
verify(mockTopScope).set("<attribute>/xpath/expression", s"<expression-$i>", false)
1061-
}
1062-
}
1063-
1064-
"""<attribute> <is|will be> defined in <reference> by regex "<expression>"""" should "evaluate" in {
1039+
"""<attribute> is defined in <reference> by regex "<expression>"""" should "evaluate" in {
10651040
doReturn(mockTopScope).when(envState).topScope
1066-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1067-
evaluate(s"""<attribute> $x defined in <reference-$i> by regex "<expression-$i>"""")
1068-
verify(mockTopScope).set(s"<attribute>/regex/source", s"<reference-$i>", false)
1069-
verify(mockTopScope).set(s"<attribute>/regex/expression", s"<expression-$i>", false)
1070-
}
1041+
evaluate(s"""<attribute> is defined in <reference-0> by regex "<expression-0>"""")
1042+
verify(mockTopScope).set(s"<attribute>/regex/source", s"<reference-0>", false)
1043+
verify(mockTopScope).set(s"<attribute>/regex/expression", s"<expression-0>", false)
10711044
}
10721045

1073-
"""<attribute> <is|will be> defined in <reference> by json path "<expression>"""" should "evaluate" in {
1046+
"""<attribute> is defined in <reference> by json path "<expression>"""" should "evaluate" in {
10741047
doReturn(mockTopScope).when(envState).topScope
1075-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1076-
evaluate(s"""<attribute> $x defined in <reference-$i> by json path "<expression-$i>"""")
1077-
verify(mockTopScope).set(s"<attribute>/json path/source", s"<reference-$i>", false)
1078-
verify(mockTopScope).set(s"<attribute>/json path/expression", s"<expression-$i>", false)
1079-
}
1048+
evaluate(s"""<attribute> is defined in <reference-0> by json path "<expression-0>"""")
1049+
verify(mockTopScope).set(s"<attribute>/json path/source", s"<reference-0>", false)
1050+
verify(mockTopScope).set(s"<attribute>/json path/expression", s"<expression-0>", false)
10801051
}
10811052

1082-
"""<attribute> <is|will be> "<value>"""" should "evaluate" in {
1083-
List("is", "will be").zipWithIndex.foreach { case (x, i) =>
1084-
evaluate(s"""<attribute-$i> $x "<value-$i>"""")
1085-
verify(mockTopScope).set(s"<attribute-$i>", s"<value-$i>", false)
1086-
}
1053+
"""<attribute> is "<value>"""" should "evaluate" in {
1054+
evaluate(s"""<attribute-0> is "<value-0>"""")
1055+
verify(mockTopScope).set(s"<attribute-0>", s"<value-0>", false)
10871056
}
10881057

10891058
"@Timeout('1s') I wait for <element> text" should "evaluate" in {
@@ -1604,28 +1573,24 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before
16041573
}
16051574
}
16061575

1607-
"""<reference> <is|will be> defined by sql "<selectStmt>" in the <dbName> database""" should "evaluate" in {
1576+
"""<reference> is defined by sql "<selectStmt>" in the <dbName> database""" should "evaluate" in {
16081577
doReturn(mockTopScope).when(envState).topScope
16091578
withSetting("gwen.db.<dbName>.driver", "driver") {
16101579
withSetting("gwen.db.<dbName>.url", "url") {
1611-
List("is", "will be").foreach { x =>
1612-
evaluate(s"""<reference> $x defined by sql "<selectStmt>" in the <dbName> database""")
1613-
}
1614-
verify(mockTopScope, times(2)).set(s"<reference>/sql/selectStmt", "<selectStmt>", false)
1615-
verify(mockTopScope, times(2)).set(s"<reference>/sql/dbName", "<dbName>", false)
1580+
evaluate(s"""<reference> is defined by sql "<selectStmt>" in the <dbName> database""")
1581+
verify(mockTopScope).set(s"<reference>/sql/selectStmt", "<selectStmt>", false)
1582+
verify(mockTopScope).set(s"<reference>/sql/dbName", "<dbName>", false)
16161583
}
16171584
}
16181585
}
16191586

1620-
"""<reference> <is|will be> defined in the <dbName> database by sql "<selectStmt>"""" should "evaluate" in {
1587+
"""<reference> is defined in the <dbName> database by sql "<selectStmt>"""" should "evaluate" in {
16211588
doReturn(mockTopScope).when(envState).topScope
16221589
withSetting("gwen.db.<dbName>.driver", "driver") {
16231590
withSetting("gwen.db.<dbName>.url", "url") {
1624-
List("is", "will be").foreach { x =>
1625-
evaluate(s"""<reference> $x defined in the <dbName> database by sql "<selectStmt>"""")
1626-
}
1627-
verify(mockTopScope, times(2)).set(s"<reference>/sql/selectStmt", "<selectStmt>", false)
1628-
verify(mockTopScope, times(2)).set(s"<reference>/sql/dbName", "<dbName>", false)
1591+
evaluate(s"""<reference> is defined in the <dbName> database by sql "<selectStmt>"""")
1592+
verify(mockTopScope).set(s"<reference>/sql/selectStmt", "<selectStmt>", false)
1593+
verify(mockTopScope).set(s"<reference>/sql/dbName", "<dbName>", false)
16291594
}
16301595
}
16311596
}

0 commit comments

Comments
 (0)