Skip to content

Commit bf07568

Browse files
committed
Add new DynamicVariableGenerators
Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 88a99f6 commit bf07568

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.idea/kotlinc.xml

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

buildSrc/src/main/kotlin/revoman.kt-conventions.gradle.kts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* http://www.apache.org/licenses/LICENSE-2.0
66
* ************************************************************************************************
77
*/
8-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
8+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
99

1010
plugins {
1111
kotlin("jvm")
@@ -20,12 +20,10 @@ kapt {
2020
useBuildCache = true
2121
}
2222

23-
tasks {
24-
withType<KotlinCompile> {
25-
kotlinOptions {
26-
// ! "-Xjvm-default=all" is needed for Immutables to work with Kotlin default methods
27-
// https://kotlinlang.org/docs/java-to-kotlin-interop.html#compatibility-modes-for-default-methods
28-
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xcontext-receivers", "-Xjdk-release=11")
29-
}
30-
}
23+
kotlin {
24+
compilerOptions {
25+
languageVersion.set(KOTLIN_2_0)
26+
apiVersion.set(KOTLIN_2_0)
27+
freeCompilerArgs.addAll("-Xjvm-default=all", "-Xcontext-receivers", "-Xjdk-release=11")
28+
}
3129
}

libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
kotlin = "2.0.0-RC3"
3-
moshix = "0.26.0-alpha03"
3+
moshix = "0.27.0-alpha01"
44
http4k = "5.19.0.0"
55
immutables = "2.10.1"
66
arrow = "1.2.4"

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import org.apache.commons.lang3.RandomStringUtils
1919
private val faker = faker {}
2020

2121
/**
22-
* [Postman
23-
* Variables](https://learning.postman.com/docs/writing-scripts/script-references/variables-list/)
22+
* @see <a
23+
* href="https://learning.postman.com/docs/writing-scripts/script-references/variables-list/">Postman
24+
* Variables</a>
2425
*/
2526
private val dynamicVariableGenerators: Map<String, () -> String> =
2627
mapOf(
@@ -34,6 +35,12 @@ private val dynamicVariableGenerators: Map<String, () -> String> =
3435
"\$randomBoolean" to { nextBoolean().toString() },
3536
"\$randomInt" to { nextInt(0, Int.MAX_VALUE).toString() },
3637
"\$randomColor" to faker.color::name,
38+
"\$randomHexColor" to { "#${getRandomHex()}${getRandomHex()}${getRandomHex()}" },
39+
// Internet and IP addresses
40+
"\$randomIP" to faker.internet::iPv4Address,
41+
"\$randomIPV6" to faker.internet::iPv6Address,
42+
"\$randomMACAddress" to { faker.internet.macAddress() },
43+
"\$randomPassword" to { RandomStringUtils.randomAlphanumeric(15) },
3744
// Names
3845
"\$randomFirstName" to faker.name::firstName,
3946
"\$randomLastName" to faker.name::lastName,
@@ -55,6 +62,8 @@ private val dynamicVariableGenerators: Map<String, () -> String> =
5562
},
5663
)
5764

65+
fun getRandomHex() = nextInt(255).toString(16).uppercase()
66+
5867
private val dynamicVariableGeneratorsWithPM: Map<String, (PostmanSDK) -> String> =
5968
mapOf("\$currentRequestName" to { it.info.requestName })
6069

0 commit comments

Comments
 (0)