Closed pnsantos closed 2 years ago
Would love to see an official response to this. There's hardly any information in RequestDefinition
so it's impossible to assert on the requests made without a cast to HttpRequest
which isn't type safe.
Mockserver is supposed to follow SemVer but this is a breaking change released as a minor version, how has this happened?
I guess we're sticking on 5.10.0
Hello, any official response about this ?
I faced today this issue breaking all our test, we will stick to 5.10.0, until a solution, or an official response if there is any
We have the same issue where this breaking change was made and I'm not sure how/if I can update our code calling retrieveRecordedRequests
to use this new version. Any advice would be appreciated.
What is the progress on this ?
Adding my voice here, this needs to be resolved since it's a breaking change; I wouldn't care as much about following sem-ver if there was at least some documentation about how to accommodate this.
EDIT: Btw, casting for me is not sufficient. Tests throw a ClassCastException when trying to do this.
I figured out one workaround for this issue. Here is the code. You have to be sure to cast each element of the array, not the full array (which was my initial failure when I posed previously). This works for us:
Optional<HttpRequest[]> result = Optional.of(Arrays.stream(mockServerClient
.retrieveRecordedRequests(
request()
.withPath("/my/path")
.withMethod("POST")))
// Cast is required after breaking change in mockserver-client around 5.11.2. Perhaps future
// versions will improve this and remove need for cast.
.map(x -> (HttpRequest) x)
.toArray(HttpRequest[]::new)
);
This will be fixed next and released in the next release due in a couple of weeks
Describe the issue
Between 5.10 and 5.11 (https://github.com/mock-server/mockserver/commit/b17f09796d6e645bce603deb02e7603977a35ace#diff-9ef4b74a33d39e5857ebb8bc5b9b5e2776b6db042587cd523a47d6062e95e39c) there seems to have been a change in several method signatures of
MockServerClient
that kinda broke the API...Previously the
retrieveRecordedRequest
returnedorg.mockserver.model.HttpRequest
but in 5.11.x the return type was changed toorg.mockserver.model.RequestDefinition
(this class doesn't give any access to the request data...)The example on the website at https://www.mock-server.com/proxy/record_and_replay.html still shows this:
However the return type in 5.11 is now
RequestDefinition
. Are we suppose to cast it toHttpRequest
? (I tried and it works but seems a bit awkward...)What you are trying to do
Trying to retrieve a recorded request
MockServer version
5.11.2
To Reproduce
Expected behaviour
MockServer Log