Skip to content

Commit 11caa43

Browse files
committed
Allow null values in Dynamic environment
Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent be7b4a1 commit 11caa43

File tree

6 files changed

+47
-65
lines changed

6 files changed

+47
-65
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MODULE.bazel.lock

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

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ node { nodeProjectDir = file("${project.projectDir}/js") }
6565
tasks {
6666
check { dependsOn(npmInstall) }
6767
test { dependsOn(npmInstall) }
68-
withType<Jar> { archiveBaseName = "revoman" }
6968
}
7069

7170
kover { reports { total { html { onCheck = true } } } }

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.8.3"
9+
const val VERSION = "0.80.4"
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: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import com.squareup.moshi.Json;
3636
import java.util.List;
3737
import java.util.Map;
38+
import kotlin.Pair;
39+
import kotlin.collections.MapsKt;
3840
import org.http4k.core.Request;
3941
import org.jetbrains.annotations.NotNull;
4042
import org.junit.jupiter.api.Test;
@@ -57,10 +59,9 @@ class PokemonTest {
5759
@Test
5860
void pokemon() {
5961
final var newLimit = 1;
60-
final var dynamicEnvironment1 =
61-
Map.of("offset", String.valueOf(OFFSET));
62-
final var dynamicEnvironment2 =
63-
Map.of("limit", String.valueOf(LIMIT));
62+
final var dynamicEnvironment1 = Map.of("offset", String.valueOf(OFFSET));
63+
final var dynamicEnvironment2 =
64+
MapsKt.mapOf(new Pair<>("limit", String.valueOf(LIMIT)), new Pair<>("null", null));
6465
@SuppressWarnings("Convert2Lambda")
6566
final var preLogHook =
6667
Mockito.spy(
@@ -127,38 +128,40 @@ public void accept(@NotNull StepReport stepReport, @NotNull Rundown rundown) {
127128
assertThat(id.id()).isEqualTo(rundown.mutableEnv.get("id"));
128129
}
129130
});
131+
final var config =
132+
Kick.configure()
133+
.templatePath(PM_COLLECTION_PATH)
134+
.environmentPath(PM_ENVIRONMENT_PATH)
135+
.responseConfig(unmarshallResponse(afterStepName("all-pokemon"), AllPokemon.class))
136+
.hooks(
137+
pre(beforeStepName("all-pokemon"), preStepHookBeforeStepName),
138+
post(afterStepName("all-pokemon"), postStepHookAfterStepName),
139+
post(afterStepContainingURIPathOfAny("pokemon-color"), postStepHookAfterURIPath),
140+
pre(beforeStepContainingHeader("preLog"), preLogHook),
141+
post(afterStepContainingHeader("postLog"), postLogHook))
142+
.dynamicEnvironment(dynamicEnvironment1)
143+
.off();
130144
final var pokeRundown =
131145
ReVoman.revUp(
132-
Kick.configure()
133-
.templatePath(PM_COLLECTION_PATH)
134-
.environmentPath(PM_ENVIRONMENT_PATH)
135-
.responseConfig(unmarshallResponse(afterStepName("all-pokemon"), AllPokemon.class))
136-
.hooks(
137-
pre(beforeStepName("all-pokemon"), preStepHookBeforeStepName),
138-
post(afterStepName("all-pokemon"), postStepHookAfterStepName),
139-
post(
140-
afterStepContainingURIPathOfAny("pokemon-color"), postStepHookAfterURIPath),
141-
pre(beforeStepContainingHeader("preLog"), preLogHook),
142-
post(afterStepContainingHeader("postLog"), postLogHook))
143-
.dynamicEnvironment(plus(dynamicEnvironment1, dynamicEnvironment2))
144-
.off());
146+
config.overrideDynamicEnvironment(plus(dynamicEnvironment1, dynamicEnvironment2)));
145147

146148
final var postHookFailure = pokeRundown.firstUnIgnoredUnsuccessfulStepReport().failure;
147149
assertThat(postHookFailure).containsLeftInstanceOf(PostStepHookFailure.class);
148150
assertThat(postHookFailure.getLeft().getFailure()).isEqualTo(RUNTIME_EXCEPTION);
149151
assertThat(pokeRundown.stepReports).hasSize(5);
150152
assertThat(pokeRundown.mutableEnv)
151153
.containsExactlyEntriesIn(
152-
Map.of(
153-
"offset", String.valueOf(OFFSET),
154-
"limit", String.valueOf(newLimit),
155-
"baseUrl", "https://pokeapi.co/api/v2",
156-
"id", "1",
157-
"pokemonName", "bulbasaur",
158-
"color", "black",
159-
"gender", "female",
160-
"ability", "stench",
161-
"nature", "hardy"));
154+
MapsKt.mapOf(
155+
new Pair<>("offset", String.valueOf(OFFSET)),
156+
new Pair<>("limit", String.valueOf(newLimit)),
157+
new Pair<>("baseUrl", "https://pokeapi.co/api/v2"),
158+
new Pair<>("id", "1"),
159+
new Pair<>("pokemonName", "bulbasaur"),
160+
new Pair<>("color", "black"),
161+
new Pair<>("gender", "female"),
162+
new Pair<>("ability", "stench"),
163+
new Pair<>("nature", "hardy"),
164+
new Pair<>("null", null)));
162165
Mockito.verify(preStepHookBeforeStepName, times(1)).accept(any(), any(), any());
163166
Mockito.verify(postStepHookAfterStepName, times(1)).accept(any(), any());
164167
Mockito.verify(postStepHookAfterURIPath, times(1)).accept(any(), any());

src/main/kotlin/com/salesforce/revoman/input/config/KickDef.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal interface KickDef {
3535

3636
fun environmentInputStreams(): List<InputStream>
3737

38-
fun dynamicEnvironment(): Map<String, Any?>
38+
@AllowNulls fun dynamicEnvironment(): Map<String, Any?>
3939

4040
fun nodeModulesPath(): String?
4141

@@ -95,7 +95,7 @@ internal interface KickDef {
9595
"`runOnlySteps` and `skipSteps` cannot contain same step names"
9696
}
9797
}
98-
98+
9999
companion object {
100100
@JvmStatic
101101
@SafeVarargs
@@ -104,6 +104,8 @@ internal interface KickDef {
104104
}
105105
}
106106

107+
annotation class AllowNulls
108+
107109
fun interface CustomDynamicVariableGenerator {
108110
fun generate(variableName: String, currentStepReport: StepReport, rundown: Rundown): String
109111
}

0 commit comments

Comments
 (0)