Skip to content

Commit 051a691

Browse files
committed
Add new random variables
Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 024c621 commit 051a691

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
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.

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
api(libs.kotlin.vavr)
2424
api(libs.arrow.core)
2525
api(libs.kotlinx.datetime)
26+
implementation(libs.apache.commons.lang3)
2627
implementation(libs.bundles.kotlin.logging)
2728
implementation(libs.pprint)
2829
implementation(libs.graal.sdk)

libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[versions]
22
kotlin = "1.9.24"
33
http4k = "5.19.0.0"
4+
immutables = "2.10.1"
45
moshix = "0.25.1"
56
arrow = "1.2.4"
67
graal = "22.3.3" # 22.3.3 Compatable with Java 11
@@ -18,7 +19,7 @@ kotlin-logging = "6.0.9"
1819
pprint = "2.0.2"
1920
underscore = "1.101"
2021
kotlin-faker = "1.16.0"
21-
immutables = "2.10.1"
22+
apache-commons-lang3 = "3.14.0"
2223
mockito = "5.11.0"
2324
spring = "5.3.31" # 5.3.31 Compatable with Java 11
2425
json-assert = "1.5.1"
@@ -68,6 +69,7 @@ mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
6869
spring-beans = { module = "org.springframework:spring-beans", version.ref = "spring" }
6970
json-assert = { module = "org.skyscreamer:jsonassert", version.ref = "json-assert" }
7071
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime-jvm", version.ref = "kotlinx-datetime" }
72+
apache-commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "apache-commons-lang3" }
7173
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
7274

7375
# Gradle plugins

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,48 @@
88
package com.salesforce.revoman.internal.postman
99

1010
import io.github.serpro69.kfaker.faker
11+
import kotlinx.datetime.Clock
12+
import org.apache.commons.lang3.RandomStringUtils
1113
import java.time.LocalDate
1214
import java.util.*
15+
import kotlin.random.Random.Default.nextBoolean
1316
import kotlin.random.Random.Default.nextInt
1417
import kotlin.random.Random.Default.nextLong
1518

1619
private val faker = faker {}
1720

21+
/**
22+
* https://learning.postman.com/docs/writing-scripts/script-references/variables-list/
23+
*/
1824
private val dynamicVariableGenerators: Map<String, () -> String> =
1925
mapOf(
26+
// Common
27+
"\$guid" to { UUID.randomUUID().toString() },
28+
"\$timestamp" to { Clock.System.now().epochSeconds.toString() },
29+
"\$isoTimestamp" to { Clock.System.now().toString() },
30+
"\$randomUUID" to { UUID.randomUUID().toString() },
31+
// Text, numbers, and colors
32+
"\$randomAlphaNumeric" to { RandomStringUtils.randomAlphanumeric(1) },
33+
"\$randomBoolean" to { nextBoolean().toString() },
34+
"\$randomInt" to { nextInt(0, Int.MAX_VALUE).toString() },
35+
"\$randomColor" to faker.color::name,
36+
// Names
2037
"\$randomFirstName" to faker.name::firstName,
2138
"\$randomLastName" to faker.name::lastName,
2239
"\$randomUserName" to { faker.name.firstName() + faker.name.lastName() },
40+
// Phone, address, and location
2341
"\$randomCity" to faker.address::city,
42+
// Grammar
2443
"\$randomWord" to faker.lorem::words,
2544
"\$randomCompanyName" to faker.company::name,
26-
"\$randomColor" to faker.color::name,
2745
"\$randomWord" to faker.lorem::words,
28-
"\$randomInt" to { nextInt(0, Int.MAX_VALUE).toString() },
2946
"\$randomAdjective" to faker.adjective::positive,
30-
"\$guid" to { UUID.randomUUID().toString() },
31-
"\$randomUUID" to { UUID.randomUUID().toString() },
3247
"\$randomEmail" to { faker.internet.email() },
3348
"\$currentDate" to { LocalDate.now().toString() },
3449
"\$randomFutureDate" to
3550
{
3651
LocalDate.now().let { it.plusDays(nextLong(1, it.lengthOfYear().toLong())).toString() }
3752
},
38-
"\$timestamp" to { System.currentTimeMillis().toString() },
3953
)
4054

4155
private val dynamicVariableGeneratorsWithPM: Map<String, (PostmanSDK) -> String> =

0 commit comments

Comments
 (0)