Skip to content

Commit 71560ca

Browse files
committed
- Update restful-api.dev.postman_collection.json to add Update request
- Minor renaming in PokemonTest Signed-off-by: Gopal S Akshintala <gopala.akshintala@salesforce.com>
1 parent 541e931 commit 71560ca

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

detekt/baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<ID>MagicNumber:Constants.kt$499</ID>
1515
<ID>MagicNumber:Constants.kt$200</ID>
1616
<ID>MagicNumber:Constants.kt$299</ID>
17+
<ID>FunctionNaming:RestfulAPIDevKtTest.kt$RestfulAPIDevKtTest$@Test fun `execute restful-api dev pm collection`()</ID>
1718
</ManuallySuppressedIssues>
1819
<CurrentIssues/>
1920
</SmellBaseline>

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,42 +60,42 @@ void pokemon() {
6060
Map.of(
6161
"offset", String.valueOf(OFFSET),
6262
"limit", String.valueOf(LIMIT));
63-
//noinspection Convert2Lambda
63+
@SuppressWarnings("Convert2Lambda")
6464
final var preLogHook =
6565
Mockito.spy(
6666
new PreStepHook() {
6767
@Override
6868
public void accept(
6969
@NotNull Step currentStep,
70-
@NotNull TxnInfo<Request> requestInfo,
71-
@NotNull Rundown rundown) {
70+
@NotNull TxnInfo<Request> ignore1,
71+
@NotNull Rundown ignore2) {
7272
LOGGER.info("Picked `preLogHook` before stepName: {}", currentStep);
7373
}
7474
});
75-
//noinspection Convert2Lambda
75+
@SuppressWarnings("Convert2Lambda")
7676
final var postLogHook =
7777
Mockito.spy(
7878
new PostStepHook() {
7979
@Override
80-
public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
80+
public void accept(@NotNull StepReport stepReport, @NotNull Rundown ignore) {
8181
LOGGER.info("Picked `postLogHook` after stepName: {}", stepReport.step.displayName);
8282
throw RUNTIME_EXCEPTION;
8383
}
8484
});
85-
//noinspection Convert2Lambda
86-
final var preStepHook =
85+
@SuppressWarnings("Convert2Lambda")
86+
final var preStepHookBeforeStepName =
8787
Mockito.spy(
8888
new PreStepHook() {
8989
@Override
9090
public void accept(
91-
@NotNull Step currentStep,
92-
@NotNull TxnInfo<Request> requestInfo,
91+
@NotNull Step ignore1,
92+
@NotNull TxnInfo<Request> ignore2,
9393
@NotNull Rundown rundown) {
9494
rundown.mutableEnv.set("limit", String.valueOf(newLimit));
9595
}
9696
});
97-
//noinspection Convert2Lambda
98-
final var postStepHook =
97+
@SuppressWarnings("Convert2Lambda")
98+
final var postStepHookAfterStepName =
9999
Mockito.spy(
100100
new PostStepHook() {
101101
@Override
@@ -106,14 +106,14 @@ public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
106106
assertThat(results.size()).isEqualTo(newLimit);
107107
}
108108
});
109-
//noinspection Convert2Lambda
110-
final var postHookAfterURIPath =
109+
@SuppressWarnings("Convert2Lambda")
110+
final var postStepHookAfterURIPath =
111111
Mockito.spy(
112112
new PostStepHook() {
113113
@Override
114114
public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
115115
LOGGER.info(
116-
"Picked `postHookAfterURIPath` after stepName: {} with raw URI: {}",
116+
"Picked `postStepHookAfterURIPath` after stepName: {} with raw URI: {}",
117117
stepReport.step.displayName,
118118
stepReport.step.rawPMStep.getRequest().url);
119119
final var id =
@@ -133,9 +133,10 @@ public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
133133
.environmentPath(PM_ENVIRONMENT_PATH)
134134
.responseConfig(unmarshallResponse(afterStepName("all-pokemon"), AllPokemon.class))
135135
.hooks(
136-
pre(beforeStepName("all-pokemon"), preStepHook),
137-
post(afterStepName("all-pokemon"), postStepHook),
138-
post(afterStepContainingURIPathOfAny("pokemon-color"), postHookAfterURIPath),
136+
pre(beforeStepName("all-pokemon"), preStepHookBeforeStepName),
137+
post(afterStepName("all-pokemon"), postStepHookAfterStepName),
138+
post(
139+
afterStepContainingURIPathOfAny("pokemon-color"), postStepHookAfterURIPath),
139140
pre(beforeStepContainingHeader("preLog"), preLogHook),
140141
post(afterStepContainingHeader("postLog"), postLogHook))
141142
.dynamicEnvironment(dynamicEnvironment)
@@ -157,9 +158,9 @@ public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
157158
"gender", "female",
158159
"ability", "stench",
159160
"nature", "hardy"));
160-
Mockito.verify(preStepHook, times(1)).accept(any(), any(), any());
161-
Mockito.verify(postStepHook, times(1)).accept(any(), any());
162-
Mockito.verify(postHookAfterURIPath, times(1)).accept(any(), any());
161+
Mockito.verify(preStepHookBeforeStepName, times(1)).accept(any(), any(), any());
162+
Mockito.verify(postStepHookAfterStepName, times(1)).accept(any(), any());
163+
Mockito.verify(postStepHookAfterURIPath, times(1)).accept(any(), any());
163164
Mockito.verify(preLogHook, times(1)).accept(any(), any(), any());
164165
Mockito.verify(postLogHook, times(1)).accept(any(), any());
165166
}

src/integrationTest/resources/pm-templates/restfulapidev/restful-api.dev.postman_collection.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"exec": [
4545
"var responseJson = pm.response.json();",
4646
"pm.environment.set(\"objId\", responseJson.id);",
47-
"pm.environment.set(\"data\", responseJson.data)"
47+
"pm.environment.set(\"data\", responseJson.data)",
48+
"pm.environment.set(\"productName\", responseJson.name)"
4849
],
4950
"type": "text/javascript",
5051
"packages": {}
@@ -91,7 +92,7 @@
9192
"response": []
9293
},
9394
{
94-
"name": "add-object-2",
95+
"name": "update-object",
9596
"event": [
9697
{
9798
"listen": "test",
@@ -121,31 +122,26 @@
121122
}
122123
],
123124
"request": {
124-
"method": "POST",
125-
"header": [
126-
{
127-
"key": "Content-Type",
128-
"value": "application/json",
129-
"type": "text"
130-
}
131-
],
125+
"method": "PATCH",
126+
"header": [],
132127
"body": {
133128
"mode": "raw",
134-
"raw": "{\n \"name\": \"{{$randomProduct}}\", // Dynamic variable\n \"data\": {\n \"year\": {{$currentYear}}, // Variable set via Pre-req\n \"price\": {{$randomPrice}} // Variable set via Pre-req\n }\n}",
129+
"raw": "{\n \"name\": \"updated - {{productName}}\" // Update Name\n}",
135130
"options": {
136131
"raw": {
137132
"language": "json"
138133
}
139134
}
140135
},
141136
"url": {
142-
"raw": "https://{{uri}}/objects",
137+
"raw": "https://{{uri}}/objects/{{objId}}",
143138
"protocol": "https",
144139
"host": [
145140
"{{uri}}"
146141
],
147142
"path": [
148-
"objects"
143+
"objects",
144+
"{{objId}}"
149145
]
150146
}
151147
},

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

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

1010
package com.salesforce.revoman.input
1111

12+
import java.io.File
13+
import java.io.InputStream
1214
import okio.BufferedSource
1315
import okio.FileSystem.Companion.RESOURCES
1416
import okio.FileSystem.Companion.SYSTEM
1517
import okio.Path.Companion.toPath
1618
import okio.buffer
1719
import okio.source
18-
import java.io.File
19-
import java.io.InputStream
2020

2121
fun bufferFile(filePath: String): BufferedSource =
2222
filePath.toPath().let { (if (it.isAbsolute) SYSTEM else RESOURCES).source(it).buffer() }
2323

24-
fun readFileToString(filePath: String): String =
25-
bufferFile(filePath).readUtf8()
24+
fun readFileToString(filePath: String): String = bufferFile(filePath).readUtf8()
2625

2726
fun bufferInputStream(inputStream: InputStream): BufferedSource = inputStream.source().buffer()
2827

0 commit comments

Comments
 (0)