-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add hypermedia autoconfiguration for WebTestClient. #20372
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
Add hypermedia autoconfiguration for WebTestClient. #20372
Conversation
public class HypermediaTestAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean |
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.
This will back off if any other CodecCustomizer
beans exist. I suspect that isn't what you want.
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.
Certainly not.
I wanted to guard against the other branch that introduces WebClient
support (#20374) and basically has the same type of bean. Just in another module. And of course, NOT backing off for just ANY CodecCustomizer
.
Suggestions? Perhaps drop the backing off policy here and now, and then resolve such bean conflicts when we get to #20374?
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.
The CodecCustomizer
here and in #20374 seem to be identical. I suspect it could be defined in one place. If so, it should probably be in spring-boot-autoconfigure
. It could then be included via spring.factories
in the relevant test auto-configuration as well.
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.
I guess I seemed to have issues (initially) with spring-boot-test-autoconfigure
seeing things so I copied it.
Let me polish up #20374 applying some of these comments there. After that is merged, I can rebase this to use that.
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.*; |
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 don't use wildcard imports in Spring Boot's codebase. Building the project locally should show any problems like these as they're enforced by Checkstyle and Spring Java Format.
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.
;)
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
/** | ||
* @author Greg Turnquist |
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.
Could you add a description of the class please? Something like the following:
Auto-configuration for using hypermedia with {@link WebTestClient}.
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.
Done
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
@ConditionalOnClass({WebTestClient.class}) |
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.
I think this will need for be @ConditionalOnClass
for HypermediaMappingInformation
, ObjectMapper
, and perhaps Jackson2JsonDecoder
as well.
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.
Done.
ca1b4c8
to
fd55ff3
Compare
@wilkinsona applied all corrections. |
e28140b
to
ab4f6f1
Compare
* Provide CodecCustomizer to support WebClient. * Add tests to verify one mediatype, multiple mediatypes, and custom mediatypes all properly register with WebClient and CodecConfigurer. Related: spring-projects#16020
* Write test cases that verify WebTestClient will pick up the same autoconfiguration beans created for WebClient. * Verify it handles one mediatype, multiple mediatypes, and custom mediatypes. Related: spring-projects#16020. Resolves spring-projects#20372.
ab4f6f1
to
a8a7782
Compare
* Write test cases that verify WebTestClient will pick up the same autoconfiguration beans created for WebClient. * Verify it handles one mediatype, multiple mediatypes, and custom mediatypes. Related: spring-projects#16020. Resolves spring-projects#20372.
a8a7782
to
93f1516
Compare
* Write test cases that verify WebTestClient will pick up the same autoconfiguration beans created for WebClient. * Verify it handles one mediatype, multiple mediatypes, and custom mediatypes. Related: spring-projects#16020. Resolves spring-projects#20372.
93f1516
to
f4bab0c
Compare
* Write test cases that verify WebTestClient will pick up the same autoconfiguration beans created for WebClient. * Verify it handles one mediatype, multiple mediatypes, and custom mediatypes. Related: spring-projects#16020. Resolves spring-projects#20372.
f4bab0c
to
91b181c
Compare
After #20374, can you review this one, @wilkinsona? |
Per our video chat,
|
Related: #16020.