Skip to content

Commit c6746dd

Browse files
committed
Release 0.5.0
- envInPostmanEnvJSONFormat - Renamed some methods in PreTxnStepPick and PostTxnStepPick Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 3068d17 commit c6746dd

File tree

22 files changed

+394
-83
lines changed

22 files changed

+394
-83
lines changed

MODULE.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
###############################################################################
2+
# Bazel now uses Bzlmod by default to manage external dependencies.
3+
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
4+
#
5+
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
6+
###############################################################################

MODULE.bazel.lock

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.adoc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif::[]
1818
:pmtemplates: src/integrationTest/resources/pm-templates
1919
:imagesdir: docs/images
2020
:prewrap!:
21-
:revoman-version: 0.42.5
21+
:revoman-version: 0.5.0
2222

2323
'''
2424

@@ -37,7 +37,7 @@ image::manual-to-automation.png[Manual to Automation, align="center"]
3737

3838
[.lead]
3939
It strikes a balance between _flexibility_
40-
provided by low-level tools like https://rest-assured.io/[**REST Assured**] and _ease of use_
40+
provided by low-level tools like https://rest-assured.io/[**REST Assured**] or https://cucumber.io/[**Cucumber**] and _ease of use_
4141
provided by UI tools like https://www.postman.com/[**Postman**]
4242

4343
image::hybrid-tool.png[]
@@ -235,27 +235,27 @@ final var pqRundown =
235235
afterAllStepsContainingHeader("ignoreHTTPStatusUnsuccessful")) // <7>
236236
.requestConfig( // <8>
237237
unmarshallRequest(
238-
beforeAllStepsWithURIPathEndingWith(PQ_URI_PATH),
238+
beforeStepContainingURIPathOfAny(PQ_URI_PATH),
239239
PlaceQuoteInputRepresentation.class,
240240
adapter(PlaceQuoteInputRepresentation.class)))
241241
.responseConfig( // <9>
242242
unmarshallResponse(
243-
afterAllStepsWithURIPathEndingWith(PQ_URI_PATH),
243+
afterStepContainingURIPathOfAny(PQ_URI_PATH),
244244
PlaceQuoteOutputRepresentation.class),
245245
unmarshallResponse(
246-
afterAllStepsWithURIPathEndingWith(COMPOSITE_GRAPH_URI_PATH),
246+
afterStepContainingURIPathOfAny(COMPOSITE_GRAPH_URI_PATH),
247247
CompositeGraphResponse.class,
248248
CompositeGraphResponse.ADAPTER))
249249
.hooks( // <10>
250250
pre(
251-
beforeAllStepsWithURIPathEndingWith(PQ_URI_PATH),
251+
beforeStepContainingURIPathOfAny(PQ_URI_PATH),
252252
(step, requestInfo, rundown) -> {
253253
if (requestInfo.containsHeader(IS_SYNC_HEADER)) {
254254
LOGGER.info("This is a Sync step: {}", step);
255255
}
256256
}),
257257
post(
258-
afterAllStepsWithURIPathEndingWith(PQ_URI_PATH),
258+
afterStepContainingURIPathOfAny(PQ_URI_PATH),
259259
(stepReport, ignore) -> {
260260
validatePQResponse(stepReport); // <11>
261261
final var isSyncStep =
@@ -270,7 +270,7 @@ final var pqRundown =
270270
}
271271
}),
272272
post(
273-
afterAllStepsWithURIPathEndingWith(COMPOSITE_GRAPH_URI_PATH),
273+
afterStepContainingURIPathOfAny(COMPOSITE_GRAPH_URI_PATH),
274274
(stepReport, ignore) -> validateCompositeGraphResponse(stepReport)),
275275
post(
276276
afterStepName("query-quote-and-related-records"),
@@ -403,7 +403,7 @@ The configuration offers methods through which the execution strategy can be con
403403
A hook lets you fiddle with the execution by plugging in your code before or after a Step execution.
404404

405405
[#_step_picks]
406-
You can pass a `PreTxnStepPick/PostTxnStepPick` which is a `Predicate` used to qualify a step for Pre-/Post-Hook respectively. ReṼoman comes bundled with some predicates under the namespace `PreTxnStepPick.PickUtils/PostTxnStepPick.PickUtils` e.g `beforeAllStepsWithURIPathEndingWith`, `afterStepName` etc. If those don't fit your needs, you can write your own custom predicates too.
406+
You can pass a `PreTxnStepPick/PostTxnStepPick` which is a `Predicate` used to qualify a step for Pre-/Post-Hook respectively. ReṼoman comes bundled with some predicates under the namespace `PreTxnStepPick.PickUtils/PostTxnStepPick.PickUtils` e.g `beforeStepContainingURIPathOfAny`, `afterStepName` etc. If those don't fit your needs, you can write your own custom predicates too.
407407

408408
[source,java,indent=0,options="nowrap"]
409409
----
@@ -484,7 +484,14 @@ CAUTION: The recommendation is not to add too much code in <<Pre-req and Post-re
484484
* Environment is the only mutable-shared state across step executions, which can be used for data-passing between consumer and the library.
485485
* This can be mutated (set key-value pairs) through <<Pre-req and Post-res scripts>> (using `pm.environment.set()`) and <<#_pre_and_post_hooks,Pre-/Post-Hooks>> (using the reference `rundown.mutableEnv`) during execution.
486486

487+
==== Read Mutable Environment as Postman Environment JSON format
488+
489+
You may want to troubleshoot manually with Postman using the Mutable environment built during the ReṼoman execution.
490+
`rundown.getEnvInPostmanEnvJSONFormat()` converts the mutable environment into a Postman JSON format,
491+
so you can copy and import that conveniently into Postman.
492+
487493
==== `pmEnvSnapshot` in each StepReport
494+
488495
Each StepReport also has a `pmEnvSnapshot` to assert if a step has executed as expected and compare snapshots from different steps to examine the execution progress.
489496

490497
=== Compose Modular Executions

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
id("revoman.kt-conventions")
1212
alias(libs.plugins.moshix)
1313
alias(libs.plugins.node.gradle)
14-
alias(libs.plugins.kover)
14+
// alias(libs.plugins.kover)
1515
alias(libs.plugins.nexus.publish)
1616
alias(libs.plugins.gradle.taskinfo)
1717
}
@@ -63,7 +63,7 @@ tasks {
6363
test { dependsOn(npmInstall) }
6464
}
6565

66-
kover { reports { total { html { onCheck = true } } } }
66+
// kover { reports { total { html { onCheck = true } } } }
6767

6868
moshi { enableSealed = true }
6969

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* ************************************************************************************************
77
*/
88
const val GROUP_ID = "com.salesforce.revoman"
9-
const val VERSION = "0.42.5"
9+
const val VERSION = "0.5.0"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

docs/images/hybrid-tool.png

-21 KB
Loading

libs.versions.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ mockk = "1.13.12"
3030
gradle-taskinfo = "2.2.0"
3131

3232
# Common dependencies
33-
junit = "5.10.2"
34-
kover = "0.8.3"
33+
34+
junit = "5.11.4"
35+
kover = "0.9.0"
3536
detekt = "1.23.7"
3637
spotless = "6.25.0"
3738
apache-log4j = "2.24.0"

src/integrationTest/java/com/salesforce/revoman/integration/core/pq/PQE2EWithSMTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import static com.salesforce.revoman.input.config.HookConfig.pre;
1313
import static com.salesforce.revoman.input.config.RequestConfig.unmarshallRequest;
1414
import static com.salesforce.revoman.input.config.ResponseConfig.unmarshallResponse;
15-
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterAllStepsContainingHeader;
16-
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterAllStepsWithURIPathEndingWith;
15+
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepContainingHeader;
16+
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepContainingURIPathOfAny;
1717
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepName;
18-
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeAllStepsWithURIPathEndingWith;
18+
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeStepContainingURIPathOfAny;
1919
import static com.salesforce.revoman.integration.core.pq.adapters.ConnectInputRepWithGraphAdapter.adapter;
2020
import static com.salesforce.revoman.output.ExeType.HTTP_STATUS;
2121
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -80,31 +80,30 @@ void revUpPQ() {
8080
(ignore1, ignore2, ignore3) -> String.valueOf(Random.Default.nextInt(999) + 1))
8181
.nodeModulesRelativePath("js") // <6>
8282
.haltOnFailureOfTypeExcept(
83-
HTTP_STATUS,
84-
afterAllStepsContainingHeader("ignoreHTTPStatusUnsuccessful")) // <7>
83+
HTTP_STATUS, afterStepContainingHeader("ignoreHTTPStatusUnsuccessful")) // <7>
8584
.requestConfig( // <8>
8685
unmarshallRequest(
87-
beforeAllStepsWithURIPathEndingWith(PQ_URI_PATH),
86+
beforeStepContainingURIPathOfAny(PQ_URI_PATH),
8887
PlaceQuoteInputRepresentation.class,
8988
adapter(PlaceQuoteInputRepresentation.class)))
9089
.responseConfig( // <9>
9190
unmarshallResponse(
92-
afterAllStepsWithURIPathEndingWith(PQ_URI_PATH),
91+
afterStepContainingURIPathOfAny(PQ_URI_PATH),
9392
PlaceQuoteOutputRepresentation.class),
9493
unmarshallResponse(
95-
afterAllStepsWithURIPathEndingWith(COMPOSITE_GRAPH_URI_PATH),
94+
afterStepContainingURIPathOfAny(COMPOSITE_GRAPH_URI_PATH),
9695
CompositeGraphResponse.class,
9796
CompositeGraphResponse.ADAPTER))
9897
.hooks( // <10>
9998
pre(
100-
beforeAllStepsWithURIPathEndingWith(PQ_URI_PATH),
99+
beforeStepContainingURIPathOfAny(PQ_URI_PATH),
101100
(step, requestInfo, rundown) -> {
102101
if (requestInfo.containsHeader(IS_SYNC_HEADER)) {
103102
LOGGER.info("This is a Sync step: {}", step);
104103
}
105104
}),
106105
post(
107-
afterAllStepsWithURIPathEndingWith(PQ_URI_PATH),
106+
afterStepContainingURIPathOfAny(PQ_URI_PATH),
108107
(stepReport, ignore) -> {
109108
validatePQResponse(stepReport); // <11>
110109
final var isSyncStep =
@@ -119,7 +118,7 @@ void revUpPQ() {
119118
}
120119
}),
121120
post(
122-
afterAllStepsWithURIPathEndingWith(COMPOSITE_GRAPH_URI_PATH),
121+
afterStepContainingURIPathOfAny(COMPOSITE_GRAPH_URI_PATH),
123122
(stepReport, ignore) -> validateCompositeGraphResponse(stepReport)),
124123
post(
125124
afterStepName("query-quote-and-related-records"),

src/integrationTest/java/com/salesforce/revoman/integration/pokemon/PokemonTest.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import static com.google.common.truth.Truth.assertThat;
1111
import static com.salesforce.revoman.input.config.HookConfig.post;
1212
import static com.salesforce.revoman.input.config.HookConfig.pre;
13-
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterAllStepsContainingHeader;
13+
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepContainingHeader;
14+
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepContainingURIPathOfAny;
1415
import static com.salesforce.revoman.input.config.StepPick.PostTxnStepPick.afterStepName;
15-
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeAllStepsContainingHeader;
16+
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeStepContainingHeader;
17+
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeStepContainingURIPathOfAny;
1618
import static com.salesforce.revoman.input.config.StepPick.PreTxnStepPick.beforeStepName;
1719
import static org.mockito.ArgumentMatchers.any;
1820
import static org.mockito.Mockito.times;
@@ -59,17 +61,17 @@ public void accept(
5961
@NotNull Step currentStep,
6062
@NotNull TxnInfo<Request> requestInfo,
6163
@NotNull Rundown rundown) {
62-
LOGGER.info("Picked `preLogHook` for stepName: {}", currentStep);
64+
LOGGER.info("Picked `preLogHook` before stepName: {}", currentStep);
6365
}
6466
});
6567
//noinspection Convert2Lambda
6668
final var postLogHook =
6769
Mockito.spy(
6870
new PostHook() {
6971
@Override
70-
public void accept(@NotNull StepReport currentStepReport, @NotNull Rundown rundown) {
72+
public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
7173
LOGGER.info(
72-
"Picked `postLogHook` for stepName: {}", currentStepReport.step.displayName);
74+
"Picked `postLogHook` after stepName: {}", stepReport.step.displayName);
7375
}
7476
});
7577
//noinspection Convert2Lambda
@@ -94,6 +96,16 @@ public void accept(@NotNull StepReport ignore2, @NotNull Rundown rundown) {
9496
assertThat(rundown.mutableEnv).containsEntry("pokemonName", "bulbasaur");
9597
}
9698
});
99+
//noinspection Convert2Lambda
100+
final var postHookAfterURIPath =
101+
Mockito.spy(
102+
new PostHook() {
103+
@Override
104+
public void accept(@NotNull StepReport stepReport, @NotNull Rundown ignore) {
105+
LOGGER.info(
106+
"Picked `postHookAfterURIPath` after stepName: {} with raw URI: {}", stepReport.step.displayName, stepReport.step.rawPMStep.getRequest().url);
107+
}
108+
});
97109
final var pokeRundown =
98110
ReVoman.revUp(
99111
Kick.configure()
@@ -102,14 +114,16 @@ public void accept(@NotNull StepReport ignore2, @NotNull Rundown rundown) {
102114
.hooks(
103115
pre(beforeStepName("all-pokemon"), preHook),
104116
post(afterStepName("all-pokemon"), postHook),
105-
pre(beforeAllStepsContainingHeader("preLog"), preLogHook),
106-
post(afterAllStepsContainingHeader("postLog"), postLogHook))
117+
post(afterStepContainingURIPathOfAny("nature"), postHookAfterURIPath),
118+
pre(beforeStepContainingHeader("preLog"), preLogHook),
119+
post(afterStepContainingHeader("postLog"), postLogHook))
107120
.dynamicEnvironment(dynamicEnvironment)
108121
.haltOnAnyFailure(true)
109122
.off());
110123

111124
Mockito.verify(preHook, times(1)).accept(any(), any(), any());
112125
Mockito.verify(postHook, times(1)).accept(any(), any());
126+
Mockito.verify(postHookAfterURIPath, times(1)).accept(any(), any());
113127
Mockito.verify(preLogHook, times(1)).accept(any(), any(), any());
114128
Mockito.verify(postLogHook, times(1)).accept(any(), any());
115129
assertThat(pokeRundown.stepReports).hasSize(5);

src/main/kotlin/com/salesforce/revoman/ReVoman.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ object ReVoman {
102102
)
103103
val stepNameToReport =
104104
executeStepsSerially(pmStepsDeepFlattened, kick, moshiReVoman, regexReplacer, pm)
105-
return Rundown(stepNameToReport, kick.haltOnFailureOfTypeExcept(), pm.environment)
105+
return Rundown(stepNameToReport, pm.environment, kick.haltOnFailureOfTypeExcept(), moshiReVoman)
106106
}
107107

108108
private fun executeStepsSerially(
@@ -125,7 +125,12 @@ object ReVoman {
125125
pm.info = Info(step.name)
126126
pm.currentStepReport = preStepReport
127127
pm.rundown =
128-
Rundown(stepReports + preStepReport, kick.haltOnFailureOfTypeExcept(), pm.environment)
128+
Rundown(
129+
stepReports + preStepReport,
130+
pm.environment,
131+
kick.haltOnFailureOfTypeExcept(),
132+
moshiReVoman
133+
)
129134
pm.environment.putAll(regexReplacer.replaceVariablesInEnv(pm))
130135
val currentStepReport: StepReport = // --------### PRE-REQ-JS ###--------
131136
executePreReqJS(step, itemWithRegex, pm)

0 commit comments

Comments
 (0)