Skip to content

Commit 9ec007b

Browse files
committed
Release 0.7.7
- Support absolute path for template and environment - postmanEnvJSONFormat to return pretty JSON Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 5a420d6 commit 9ec007b

File tree

14 files changed

+48
-43
lines changed

14 files changed

+48
-43
lines changed

MODULE.bazel.lock

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

README.adoc

Lines changed: 11 additions & 8 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.6
21+
:revoman-version: 0.7.7
2222

2323
'''
2424

@@ -324,11 +324,11 @@ assertThat(pqRundown.mutableEnv)
324324
"quoteCalculationStatusAfterAllUpdates", PricingPref.System.completeStatus));
325325
----
326326
<1> `revUp()` is the method to call passing a configuration, built as below
327-
<2> Supply the path (relative to resources) to the Template Collection JSON file/files
328-
<3> Supply the path (relative to resources) to the Environment JSON file/files
327+
<2> Supply the path (absolute or relative to resources) to the Template Collection JSON file/files
328+
<3> Supply the path (absolute or relative to resources) to the Environment JSON file/files
329329
<4> Supply any dynamic environment that is runtime-specific
330330
<5> <<Custom Dynamic variables>>
331-
<6> Node modules path (relative to resources) to be used inside <<Pre-req and Post-res scripts>>
331+
<6> Node modules path (absolute or relative to project directory) to be used inside <<Pre-req and Post-res scripts>>
332332
<7> <<Execution Control>>
333333
<8> <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization, Request Config>>
334334
<9> <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization, Response Config>>
@@ -347,11 +347,11 @@ ifndef::env-github[]
347347
include::{integrationtestdir}/com/salesforce/revoman/integration/core/pq/PQE2EWithSMTest.java[tag=pq-e2e-with-revoman-config-demo]
348348
----
349349
<1> `revUp()` is the method to call passing a configuration, built as below
350-
<2> Supply the path (relative to resources) to the Template Collection JSON file/files
351-
<3> Supply the path (relative to resources) to the Environment JSON file/files
350+
<2> Supply the path (absolute or relative to resources) to the Template Collection JSON file/files
351+
<3> Supply the path (absolute or relative to resources) to the Environment JSON file/files
352352
<4> Supply any dynamic environment that is runtime-specific
353353
<5> <<Custom Dynamic variables>>
354-
<6> Node modules path (relative to resources) to be used inside <<Pre-req and Post-res scripts>>
354+
<6> Node modules path (absolute or relative to project directory) to be used inside <<Pre-req and Post-res scripts>>
355355
<7> <<Execution Control>>
356356
<8> <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization, Request Config>>
357357
<9> <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization, Response Config>>
@@ -621,7 +621,10 @@ CAUTION: When a Step qualifies for more than one hook, hooks are executed in the
621621
* ReṼoman can execute this JavaScript on JVM. This support ensures that the Postman collection used for manual testing can be used *as-is* for the automation also, without any resistance to modify or overhead of maintaining separate versions for manual and automation.
622622
** Pre-req JS script is executed as the first step before Unmarshall request.
623623
** Post-res JS script is executed right after receiving an HTTP response.
624-
* ReṼoman supports using `npm` modules inside your Pre-req and Post-res JS scripts. You can install `npm` modules in any folder using traditional commands like `npm install <module>` and supply in the `Kick` config, an absolute or relative path (relative to Project directory) to the folder that contains the `node_modules` folder using `nodeModulesPath(...)`. Use those `npm` modules inside your scripts with `require(...)`, for example:
624+
625+
==== `npm` modules to use with `require(...)`
626+
627+
ReṼoman supports using `npm` modules inside your Pre-req and Post-res JS scripts. You can install `npm` modules in any folder using traditional commands like `npm install <module>` and supply in the `Kick` config, an absolute path or relative path (relative to Project directory, for e.g., link:js[js] in this project) to the parent folder that contains the `node_modules` folder using `nodeModulesPath(...)`. Use those `npm` modules inside your scripts with `require(...)`, for example:
625628

626629
.Install `moment` with npm
627630
[source,shellscript,indent=0,options="nowrap"]

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

src/integrationTest/java/com/salesforce/revoman/input/json/JsonPojoUtils2Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package com.salesforce.revoman.input.json;
99

1010
import static com.google.common.truth.Truth.assertThat;
11-
import static com.salesforce.revoman.input.FileUtils.readFileInResourcesToString;
11+
import static com.salesforce.revoman.input.FileUtils.readFileToString;
1212
import static com.salesforce.revoman.integration.core.adapters.ConnectInputRepWithGraphAdapter.adapter;
1313
import static org.junit.jupiter.api.Assertions.assertNotNull;
1414
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -31,7 +31,7 @@ class JsonPojoUtils2Test {
3131
@DisplayName("toJson: PQ Payload JSON -> PlaceQuoteInputRep -> PQ Payload JSON")
3232
void pqInputRepToPQPayloadJson() throws JSONException {
3333
final var pqAdapter = adapter(PlaceQuoteInputRepresentation.class);
34-
final var expectedPQPayload = readFileInResourcesToString("json/pq-payload.json");
34+
final var expectedPQPayload = readFileToString("json/pq-payload.json");
3535
final var pqInputRep =
3636
JsonPojoUtils.<PlaceQuoteInputRepresentation>jsonToPojo(
3737
PlaceQuoteInputRepresentation.class, expectedPQPayload, List.of(pqAdapter));
@@ -64,7 +64,7 @@ void pqPayloadJsonToPQInputRep() {
6464
@Test
6565
@DisplayName("JSON --> PQ Response --> JSON")
6666
void unmarshallMarshallPqResponse() throws JSONException {
67-
final var pqResponseFromJson = readFileInResourcesToString("json/pq-response.json");
67+
final var pqResponseFromJson = readFileToString("json/pq-response.json");
6868
final var pqResp =
6969
JsonPojoUtils.jsonToPojo(
7070
JsonString.<PlaceQuoteOutputRepresentation>unmarshall()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import arrow.core.Either.Right
1212
import arrow.core.flatMap
1313
import arrow.core.merge
1414
import com.salesforce.revoman.input.PostExeHook
15-
import com.salesforce.revoman.input.bufferFileInResources
15+
import com.salesforce.revoman.input.bufferFile
1616
import com.salesforce.revoman.input.bufferInputStream
1717
import com.salesforce.revoman.input.config.Kick
1818
import com.salesforce.revoman.internal.exe.deepFlattenItems
@@ -80,7 +80,7 @@ object ReVoman {
8080
fun revUp(kick: Kick): Rundown {
8181
val pmTemplateAdapter = Moshi.Builder().build().adapter<Template>()
8282
val templateBuffers =
83-
kick.templatePaths().map { bufferFileInResources(it) } +
83+
kick.templatePaths().map { bufferFile(it) } +
8484
kick.templateInputStreams().map { bufferInputStream(it) }
8585
val pmStepsDeepFlattened =
8686
templateBuffers

src/main/kotlin/com/salesforce/revoman/input/FileUtils.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99

1010
package com.salesforce.revoman.input
1111

12-
import java.io.File
13-
import java.io.InputStream
1412
import okio.BufferedSource
15-
import okio.FileSystem
13+
import okio.FileSystem.Companion.RESOURCES
14+
import okio.FileSystem.Companion.SYSTEM
1615
import okio.Path.Companion.toPath
1716
import okio.buffer
1817
import okio.source
18+
import java.io.File
19+
import java.io.InputStream
1920

20-
fun bufferFileInResources(fileRelativePath: String): BufferedSource =
21-
FileSystem.RESOURCES.source(fileRelativePath.toPath()).buffer()
21+
fun bufferFile(filePath: String): BufferedSource =
22+
filePath.toPath().let { (if (it.isAbsolute) SYSTEM else RESOURCES).source(it).buffer() }
2223

23-
fun readFileInResourcesToString(fileRelativePath: String): String =
24-
bufferFileInResources(fileRelativePath).readUtf8()
24+
fun readFileToString(filePath: String): String =
25+
bufferFile(filePath).readUtf8()
2526

2627
fun bufferInputStream(inputStream: InputStream): BufferedSource = inputStream.source().buffer()
2728

@@ -32,5 +33,5 @@ fun bufferFile(file: File): BufferedSource = file.source().buffer()
3233

3334
fun readFileToString(file: File): String = bufferFile(file).readUtf8()
3435

35-
fun writeToFileInTheModule(fileRelativePath: String, content: String) =
36-
FileSystem.SYSTEM.write(fileRelativePath.toPath()) { writeUtf8(content) }
36+
fun writeToFile(filePath: String, content: String) =
37+
SYSTEM.write(filePath.toPath()) { writeUtf8(content) }

src/main/kotlin/com/salesforce/revoman/input/json/JsonPojoUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
package com.salesforce.revoman.input.json
1111

12-
import com.salesforce.revoman.input.bufferFileInResources
12+
import com.salesforce.revoman.input.bufferFile
1313
import com.salesforce.revoman.internal.json.MoshiReVoman.Companion.initMoshi
1414
import com.squareup.moshi.JsonAdapter
1515
import com.squareup.moshi.JsonAdapter.Factory
@@ -37,7 +37,7 @@ fun <PojoT : Any> jsonFileToPojo(
3737
skipTypes: Set<Class<out Any>> = emptySet(),
3838
): PojoT? {
3939
val jsonAdapter = initMoshi<PojoT>(customAdapters, customAdaptersWithType, skipTypes, pojoType)
40-
return jsonAdapter.fromJson(bufferFileInResources(jsonFilePath))
40+
return jsonAdapter.fromJson(bufferFile(jsonFilePath))
4141
}
4242

4343
fun <PojoT : Any> jsonFileToPojo(jsonFile: JsonFile<PojoT>): PojoT? =

src/main/kotlin/com/salesforce/revoman/internal/postman/Postman.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
package com.salesforce.revoman.internal.postman
99

10-
import com.salesforce.revoman.input.bufferFileInResources
10+
import com.salesforce.revoman.input.bufferFile
1111
import com.salesforce.revoman.input.bufferInputStream
1212
import com.salesforce.revoman.internal.postman.template.Environment
1313
import com.squareup.moshi.Moshi
@@ -27,7 +27,7 @@ internal fun mergeEnvs(
2727
val envAdapter = Moshi.Builder().build().adapter<Environment>()
2828
// ! TODO 05/10/23 gopala.akshintala: Consider values from env file being parsed to replace
2929
val envFileBuffers =
30-
pmEnvironmentPaths.map { bufferFileInResources(it) } +
30+
pmEnvironmentPaths.map { bufferFile(it) } +
3131
pmEnvironmentInputStreams.map { bufferInputStream(it) }
3232
val envFromEnvFiles =
3333
envFileBuffers

src/main/kotlin/com/salesforce/revoman/output/postman/PostmanEnvironment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constructor(
3232

3333
@get:JvmName("postmanEnvJSONFormat")
3434
val postmanEnvJSONFormat: String by lazy {
35-
moshiReVoman.toJson(fromMap(mutableEnv, moshiReVoman))
35+
moshiReVoman.toPrettyJson(fromMap(mutableEnv, moshiReVoman))
3636
}
3737

3838
fun set(key: String, value: ValueT) {

src/test/java/com/salesforce/revoman/input/json/JsonPojoUtilsTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package com.salesforce.revoman.input.json;
99

1010
import static com.google.common.truth.Truth.assertThat;
11-
import static com.salesforce.revoman.input.FileUtils.readFileInResourcesToString;
11+
import static com.salesforce.revoman.input.FileUtils.readFileToString;
1212

1313
import com.salesforce.revoman.input.json.adapters.SObjectGraphRequestMarshaller;
1414
import com.salesforce.revoman.input.json.adapters.salesforce.CompositeGraphResponse;
@@ -65,14 +65,14 @@ void compositeGraphResponseDiMorphicMarshallUnmarshall() throws JSONException {
6565
final var successGraphResponseUnmarshalled =
6666
JsonPojoUtils.pojoToJson(pojoToJsonConfig.pojo(successGraphResponse).done());
6767
JSONAssert.assertEquals(
68-
readFileInResourcesToString("composite/graph/resp/graph-response-success.json"),
68+
readFileToString("composite/graph/resp/graph-response-success.json"),
6969
successGraphResponseUnmarshalled,
7070
JSONCompareMode.STRICT);
7171

7272
final var errorGraphResponseUnmarshalled =
7373
JsonPojoUtils.pojoToJson(pojoToJsonConfig.pojo(errorGraphResponse).done());
7474
JSONAssert.assertEquals(
75-
readFileInResourcesToString("composite/graph/resp/graph-response-error.json"),
75+
readFileToString("composite/graph/resp/graph-response-error.json"),
7676
errorGraphResponseUnmarshalled,
7777
JSONCompareMode.STRICT);
7878
}
@@ -133,22 +133,22 @@ void compositeResponseDiMorphicMarshallUnmarshall() throws JSONException {
133133
final var successCompositeQueryResponseUnmarshalled =
134134
JsonPojoUtils.pojoToJson(pojoToJsonConfig.pojo(successCompositeQueryResponse).done());
135135
JSONAssert.assertEquals(
136-
readFileInResourcesToString("composite/query/resp/query-response-all-success.json"),
136+
readFileToString("composite/query/resp/query-response-all-success.json"),
137137
successCompositeQueryResponseUnmarshalled,
138138
JSONCompareMode.STRICT);
139139

140140
final var errorCompositeQueryResponseUnmarshalled =
141141
JsonPojoUtils.pojoToJson(pojoToJsonConfig.pojo(errorCompositeQueryResponse).done());
142142
JSONAssert.assertEquals(
143-
readFileInResourcesToString("composite/query/resp/query-response-all-error.json"),
143+
readFileToString("composite/query/resp/query-response-all-error.json"),
144144
errorCompositeQueryResponseUnmarshalled,
145145
JSONCompareMode.STRICT);
146146

147147
final var partialSuccessCompositeQueryResponseUnmarshalled =
148148
JsonPojoUtils.pojoToJson(
149149
pojoToJsonConfig.pojo(partialSuccessCompositeQueryResponse).done());
150150
JSONAssert.assertEquals(
151-
readFileInResourcesToString("composite/query/resp/query-response-partial-success.json"),
151+
readFileToString("composite/query/resp/query-response-partial-success.json"),
152152
partialSuccessCompositeQueryResponseUnmarshalled,
153153
JSONCompareMode.STRICT);
154154
}
@@ -164,7 +164,7 @@ void sObjectGraphMarshallToPQPayload() throws JSONException {
164164
SObjectGraphRequest.class,
165165
prepareSObjectGraphReqPojo(),
166166
List.of(pqTestInputRepMarshaller));
167-
final var expectedPQPayload = readFileInResourcesToString("json/pq-graph-req-masked.json");
167+
final var expectedPQPayload = readFileToString("json/pq-graph-req-masked.json");
168168
JSONAssert.assertEquals(expectedPQPayload, pqPayloadJsonStr, JSONCompareMode.STRICT);
169169
}
170170

0 commit comments

Comments
 (0)