New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring for MockServerHttpRequest #25148
Conversation
Hey Rosen (@rstoyanchev ), would you please mind taking a short look if this makes any sense to you? I could also create some small unit tests to make sure that the failure message is the same when HttpMethod null is set, but I think this is not that valuable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a reasonable simplification and the resolve
is a map lookup so it shouldn't be a concern.
URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies, | ||
@Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress, | ||
@Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) { | ||
|
||
super(uri, contextPath, headers); | ||
Assert.isTrue(httpMethod != null || customHttpMethod != null, "HTTP method must not be null"); | ||
this.httpMethod = httpMethod; | ||
this.customHttpMethod = customHttpMethod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still can assert the httpMethodValue is not null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rstoyanchev I added some easy tests, testing all possible build paths.
Should I anyways add the assertion here?
Quick question, sorry for asking this. There is another MockServerHttpRequest in
Is that auto generated or should it also receive this functionality ? |
You will need to manually copy the changes to that class to keep them in sync. |
….MockServerHttpRequest with org.springframework.mock.http.server.reactive.MockServerHttpRequest for spring-projectsgh-25109
Done |
Created a small refactoring for gh-25109.
Changed:
to DefaultBodyContructor to also catch the contructor call
to leave the main constructor easier to understand and failfast when constructing he builder.
Also, messages when calling the
would have failed with another kind of assertion message than