Skip to content

Commit a027784

Browse files
committed
Release 0.7.3
Add Request Response info in PostHookFailure Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 00984e7 commit a027784

File tree

8 files changed

+52
-24
lines changed

8 files changed

+52
-24
lines changed

README.adoc

Lines changed: 35 additions & 16 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.7.2
21+
:revoman-version: 0.7.3
2222

2323
'''
2424

@@ -38,15 +38,32 @@ image::manual-to-automation.png[Manual to Automation, align="center"]
3838
[.lead]
3939
It strikes a balance between _flexibility_
4040
provided by low-level tools like https://rest-assured.io/[**REST Assured**] or https://cucumber.io/[**Cucumber**] and _ease of use_
41-
provided by UI tools like https://www.postman.com/[**Postman**]
41+
provided by UI tools like https://www.postman.com/[**Postman**].
4242

4343
image::hybrid-tool.png[]
4444

45+
[.lead]
46+
The fundamental principle of this tool is
47+
to automate your Postman collection on JVM *without compromising on Manual testing*.
48+
Which means
49+
the collections used in JVM automation can be maintained
50+
to always be ready for Manually trying them out importing into Postman.
51+
52+
== Why not use https://learning.postman.com/docs/collections/using-newman-cli/command-line-integration-with-newman[Newman] or https://learning.postman.com/docs/postman-cli/postman-cli-overview/#comparing-the-postman-cli-and-newman[Postman CLI]?
53+
54+
* ReṼoman may be similar to Newman or Postman CLI when it comes to executing a Postman collection, but the _similarities end there_
55+
* Newman or Postman CLI are built for node and cannot be executed within a JVM. Even if you are able to run in some hacky way, there is no easy way to assert results.
56+
* ReṼoman is JVM first that lets you seamlessly integrate with your existing Java ecosystem. It lets you configure more — for example, the <<#_pre_step_and_post_step_hooks,Hooks>> feature lets you plug in your custom JVM code in-between the execution.
57+
* ReṼoman has a strong emphasis on <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization,Type-Safety>>, leveraging JVM strong types over JSON for writing assertions and custom code
58+
59+
[.lead]
60+
Read more in the <<USP>>
61+
4562
== Artifact
4663

4764
[.lead]
4865
Maven
49-
[source,xml,subs=attributes+]
66+
[source,xml,subs=attributes+,tabsize=2]
5067
----
5168
<dependency>
5269
<groupId>com.salesforce.revoman</groupId>
@@ -108,11 +125,18 @@ ____
108125

109126
=== Template-Driven Testing
110127

111-
* The exported Postman collection JSON file is referred to as a Postman template, as it contains some placeholders/variables in the `+{{variable-key}}+` pattern. You can read more about it https://learning.postman.com/docs/sending-requests/variables/[here]
112-
* ReṼoman understands these templates and replaces these variables at the runtime, similar to Postman. It supports
113-
** Nested variables, e.g., `+{{variable-key{{nested-variable-key}}}}+`
114-
** link:{sourcedir}/com/salesforce/revoman/internal/postman/DynamicVariableGenerator.kt[Dynamic variables], e.g., `{{$randomUUID}}`, `{{$randomEmail}}`
115-
** <<Custom Dynamic variables>>
128+
==== Why Postman Templates?
129+
130+
The exported Postman collection JSON file is referred to as a Postman template, as it contains some placeholders/variables in the `+{{variable-key}}+` pattern. You can read more about it https://learning.postman.com/docs/sending-requests/variables/[here].
131+
This is a popular and proven pattern that interconnects multiple requests like a Graph. This is not unique to Postman, but Postman is popular and has a full-blown UI, which makes it an attractive choice to support Postman templates. But that said, the tool is modular, and the implementation is not coupled with any Postman related contracts. *In the future, we can think of supporting more template formats*
132+
133+
==== Variable support in ReṼoman
134+
135+
* Variables, e.g., `+{{variable-key}}+`
136+
* Nested variables, e.g., `+{{variable-key{{nested-variable-key}}}}+`
137+
* link:{sourcedir}/com/salesforce/revoman/internal/postman/DynamicVariableGenerator.kt[Dynamic variables],
138+
e.g., `{{$randomUUID}}`, `{{$randomEmail}}`
139+
* <<Custom Dynamic variables>>
116140

117141
[#_variable_resolution_precedence]
118142
==== Variable resolution precedence
@@ -139,7 +163,7 @@ final var rundown =
139163

140164
=== A Simple Example
141165

142-
Here is a simple link:{pmtemplates}/restfulapidev/restful-api.dev.postman_collection.json[Exported Postman collection] and link:{pmtemplates}/restfulapidev/restful-api.dev.postman_environment.json[Environment],
166+
Here is a simple link:{pmtemplates}/restfulapidev/restful-api.dev.postman_collection.json[Exported Postman collection] and link:{pmtemplates}/restfulapidev/restful-api.dev.postman_environment.json[Environment] JSON files,
143167
to hit a free public https://restful-api.dev/[RESTFUL-API].
144168
You can import and manually test this collection through the `Run collection` button like this:
145169

@@ -214,7 +238,7 @@ StepReport(
214238
<2> Snapshot of Environment at the end of each step execution. It can be compared with previous or next step environment snapshots to see what changed in this step
215239

216240
[.lead]
217-
`Rundown` has many convenient methods to ease applying further assertions on top of it.
241+
`Rundown` has many convenient methods to ease applying further assertions on top of it. Checkout its <<#_ide_debugger_view,IDE Debugger view>>
218242

219243
TIP: Other simple examples to see in Action: link:{integrationtestdir}/com/salesforce/revoman/integration/pokemon/PokemonTest.java[PokemonTest.java]
220244

@@ -368,6 +392,7 @@ CAUTION: Iterable attributes (like `List`, `Map` etc) accept an `Iterable`. If y
368392
[#_debugging_dx]
369393
== Troubleshooting DX
370394

395+
[#_ide_debugger_view]
371396
=== IDE debugger view
372397
[.lead]
373398
This tool has a particular emphasis on the Debugging experience.Here is what a debugger view of a <<Rundown>> looks like:
@@ -737,12 +762,6 @@ You don't have to.
737762
This is a JVM-first tool,
738763
and you can interlace your TestUtils through <<#_plug_in_your_java_code_in_between_postman_execution,Pre-Step/Post-Step Hooks>>
739764

740-
=== Why not use https://learning.postman.com/docs/collections/using-newman-cli/command-line-integration-with-newman[Newman] or https://learning.postman.com/docs/postman-cli/postman-cli-overview/#comparing-the-postman-cli-and-newman[Postman CLI]?
741-
742-
* ReṼoman may be similar to Newman or Postman CLI when it comes to executing a Postman collection, but the _similarities end there_.
743-
* Newman or Postman CLI are built for node and cannot be executed within a JVM. Even if you are able to run in some hacky way, there is no easy way to assert results.
744-
* ReṼoman is JVM first that lets you configure a lot more, and gives you back a detailed report to assert in a typesafe way
745-
746765
== 🙌🏼 Consume-Collaborate-Contribute
747766

748767
* This link:CONTRIBUTING.adoc[CONTRIBUTING] doc has all the information to set up this library on your local and get hands-on.

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.7.2"
9+
const val VERSION = "0.7.3"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
141141
.dynamicEnvironment(dynamicEnvironment)
142142
.off());
143143

144-
assertThat(pokeRundown.firstUnIgnoredUnsuccessfulStepReport().failure)
145-
.containsOnLeft(new PostStepHookFailure(RUNTIME_EXCEPTION));
144+
final var postHookFailure = pokeRundown.firstUnIgnoredUnsuccessfulStepReport().failure;
145+
assertThat(postHookFailure).containsLeftInstanceOf(PostStepHookFailure.class);
146+
assertThat(postHookFailure.getLeft().getFailure()).isEqualTo(RUNTIME_EXCEPTION);
146147
assertThat(pokeRundown.stepReports).hasSize(5);
147148
assertThat(pokeRundown.mutableEnv)
148149
.containsExactlyEntriesIn(

src/main/kotlin/com/salesforce/revoman/input/json/adapters/salesforce/CompositeResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ data class CompositeResponse(val compositeResponse: List<Response>) {
7878
}
7979
attributes = attributesJsonAdapter.fromJson(reader)
8080
}
81-
-1 -> recordBody[reader.nextName()] = reader.readJsonValue()!!
81+
-1 -> recordBody[reader.nextName()] = reader.readJsonValue()
8282
else -> throw AssertionError()
8383
}
8484
}

src/main/kotlin/com/salesforce/revoman/internal/exe/PostStepHook.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal fun postStepHookExe(kick: Kick, pm: PostmanSDK): PostStepHookFailure? =
2424
runCatching(pm.currentStepReport.step, POST_STEP_HOOK) {
2525
postStepHook.accept(pm.currentStepReport, pm.rundown)
2626
}
27-
.mapLeft { PostStepHookFailure(it) }
27+
.mapLeft { PostStepHookFailure(it, pm.currentStepReport.requestInfo!!.get(), pm.currentStepReport.responseInfo!!.get()) }
2828
}
2929
.firstOrNull { it.isLeft() }
3030
?.leftOrNull()

src/main/kotlin/com/salesforce/revoman/output/report/failure/HookFailure.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ import com.salesforce.revoman.output.ExeType.POST_STEP_HOOK
1111
import com.salesforce.revoman.output.ExeType.PRE_STEP_HOOK
1212
import com.salesforce.revoman.output.report.TxnInfo
1313
import org.http4k.core.Request
14+
import org.http4k.core.Response
1415

1516
sealed class HookFailure : ExeFailure() {
1617

1718
data class PreStepHookFailure(
1819
override val failure: Throwable,
19-
val requestInfo: TxnInfo<Request>,
20+
@JvmField val requestInfo: TxnInfo<Request>,
2021
) : HookFailure() {
2122
override val exeType = PRE_STEP_HOOK
2223
}
2324

24-
data class PostStepHookFailure(override val failure: Throwable) : HookFailure() {
25+
data class PostStepHookFailure(
26+
override val failure: Throwable,
27+
@JvmField val requestInfo: TxnInfo<Request>,
28+
@JvmField val responseInfo: TxnInfo<Response>,
29+
) : HookFailure() {
2530
override val exeType = POST_STEP_HOOK
2631
}
2732
}

src/main/kotlin/com/salesforce/revoman/output/report/failure/HttpStatusUnsuccessful.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import org.http4k.core.Request
1313
import org.http4k.core.Response
1414

1515
data class HttpStatusUnsuccessful(
16+
@JvmField
1617
val requestInfo: TxnInfo<Request>,
18+
@JvmField
1719
val responseInfo: TxnInfo<Response>,
1820
) {
21+
@JvmField
1922
val exeType = HTTP_STATUS
2023
}

src/test/kotlin/com/salesforce/revoman/output/report/StepReportTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class StepReportTest {
123123
Right(requestInfo),
124124
null,
125125
Right(responseInfo),
126-
PostStepHookFailure(RuntimeException("fakeRTE")),
126+
PostStepHookFailure(RuntimeException("fakeRTE"), requestInfo, responseInfo),
127127
PostmanEnvironment(),
128128
)
129129
println(stepReportPostStepHookFailure)

0 commit comments

Comments
 (0)