In my kotlin app I have an endpoint GET /v1/money?accounts=...
where accounts
is a list with comma separated strings. I need to build a Wiremock stubbing where I’ll return that list in the response. But my variant doesn’t work:
portalWiremock.server().stubFor(
get(urlPathMatching("/v1/money?accounts=.*"))
.willReturn(
okJson(
"""
{
"trackingId": "abcde12345",
"accounts": ${'$'}{accountsList(request.queryParameter("accounts"))}
}
""".trimIndent()
)
)
)
...
fun accountsList(accountsParam: String?): String {
val accounts = accountsParam?.split(",") ?: emptyList()
val accountsJson = accounts.joinToString(",", "[", "]") { ""$it"" }
return accountsJson
}
Is there another way I should use? Is it possible in general to catch/return in that way?