Created a small refactoring for gh-25109.
Changed:
- Field duplication
- Set DefaultBodyBuilder as protected, to allow children from other packages to call constructor (it seemed very constrictive to allow the call of the contructor only from the existing package)
- Moved the
Assert.notNull(method, "HttpMethod is required. If testing a custom HTTP method, " +
"please use the variant that accepts a String based HTTP method.");
to DefaultBodyContructor to also catch the contructor call
public static BodyBuilder method(HttpMethod method, URI url) {
return new DefaultBodyBuilder(method, url);
}
to leave the main constructor easier to understand and failfast when constructing he builder. Also, messages when calling the
MockServerHttpRequest.method(null, *any URI*)
would have failed with another kind of assertion message than
MockServerHttpRequest.method(null, urlTemplate, param1, param2)
- Extended the check for the string value of HttpMethod to exclude the set of HttpMethod to only whitespaces, as this, imho, makes no sense
Comment From: midumitrescu
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
Comment From: midumitrescu
Quick question, sorry for asking this.
There is another MockServerHttpRequest in
org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest
Is that auto generated or should it also receive this functionality ?
Comment From: sbrannen
There is another MockServerHttpRequest in
You will need to manually copy the changes to that class to keep them in sync.
Comment From: midumitrescu
There is another MockServerHttpRequest in
You will need to manually copy the changes to that class to keep them in sync.
Done