wiremock / kotlin-wiremock

Kotlin DSL for WireMock

Home Page:https://wiremock.org/docs/solutions/kotlin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using `returnsJson` creates 2 mappings

checketts opened this issue · comments

Using kotlin-wiremock v1.0.3, I noticed that when using:

    wiremockServer.post {
        url equalTo "/graphql"
        body contains "matchesJsonPath" equalTo "\$.variables[?(@.id == '${person.id}')]"
    } returnsJson  {
        body = """{"name": "example"}"""
    }

Wiremock would create 2 mappings, one with an empty body and one with the one I defined. however if I use returns instead of returnsJson then only a single mapping is created on the wiremock server

OK I believe I found the root cause. The compute call in returns and returnsJson each register their stubs with WireMock.

So the side effect needs to be moved out of there to the end of the request/response creation. I would like to create a PR for that. Would that be of interest?

Hi @checketts ,

Thanks, Ok I see the issue, I looked through it but I'm not so sure if it would be easy to fix as there is no special method to indicate the end of defining specification. All of them(returns, and, returnsJson) can be last. If you have any idea how to fix, please raise a PR. Thanks.

Addressed by #18

@checketts
Thanks for PRs. I will spend some time during the weekend, merge them and release new version :)

Hi @checketts,
Thanks for noticing this bug, I fixed it in #21.
It fixes all use cases(and, returns, returnJsons)

Nice! Thanks!