Spring-cloud-contract: Dynamic properties in `queryParameters` section are not parsed

Created on 18 Jan 2019  Â·  9Comments  Â·  Source: spring-cloud/spring-cloud-contract

It looks like dynamic properties don't work for request.urlPath.queryParameters when defining contract in Groovy

Relevant part of the contract looks like that:

           request {
                method 'GET'
                urlPath('/advise') {
                    queryParameters {
                        parameter('referenceDate': $(
                                consumer(regex(iso8601WithOffset())),
                                producer(execute("todayAtNoon()"))
                        ))
                    }
                }
            }

And todayAtNoon() is a method in the base test class.
This results in generated of test code:

           // when:
            Response response = given().spec(request)
                    .queryParam("referenceDate","todayAtNoon()")

This of course causes 400 Bad Request, as we're literally sending "todayAtNoon()" string to the producer.

The version is 2.0.2.RELEASE

backlog enhancement help wanted

All 9 comments

Hello @tsayen . Thanks for reporting it. It's a good idea. Marking as enhancement and adding to backlog.

Hi @OlgaMaciaszek, I don't really see this issue as an enhancement, it's rather a bug.

The documentation clearly states you can do something like that: https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/1.1.2.RELEASE/#_executing_custom_methods_on_server_side

But it doesn't work

There is also issue #709, which is about dynamic properties, but in request headers. In that case execute() works correctly (see comment https://github.com/spring-cloud/spring-cloud-contract/issues/709#issuecomment-412446045), it just doesn't work for queryParameters

I can't decide whether it's a bug or an enhancement cause we just never supported that feature. Now, since it's requested, we can consider adding it

I also have this issue , I think it is bug

Spent half a day looking at this before realising that it's distinct to the queryParameter and not my syntax of the
producer(execute("myBaseClassTestMethod()"))

It's been a year any update on it?

As you can see nothing has changed. We're open to accepting PRs though.

If you can give me a few pointers I'd take a look?

On Mon, Mar 15, 2021 at 8:02 AM Marcin Grzejszczak @.*>
wrote:

As you can see nothing has changed. We're open to accepting PRs though.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/spring-cloud/spring-cloud-contract/issues/854#issuecomment-799203644,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAM4Y7XGBIT7EC45LNKB57TTDW5IRANCNFSM4GRAGZVQ
.

Was this page helpful?
0 / 5 - 0 ratings