I'm using Mockio, Wiremock and WebClient. I configured my WebClient to use Oauth via two Bean Methods in a class annotated with @Configuration.
@Configuration
public class WebClientConfig {
@Bean
public WebClient webClient(OAuth2AuthorizedClientManager authorizedClientManager) {
...
}
/*
Manages the auth process and token refresh process
*/
@Bean
public OAuth2AuthorizedClientManager authorizedClientManager(
ClientRegistrationRepository clientRegistrationRepository,
OAuth2AuthorizedClientRepository authorizedClientRepository) {
...
}
}
Because I want to use the webClient without oauth to call wiremock, I want to replace the Beans to return a simple Webclient.builder().build();
So I did:
@MockBean
WebClientConfig webClientConfig;
and now I'm not sure how to mock the two @Bean annotated methods and where to place them ( in @BeforeAll etc?)
I thought about something like when(webclientConfig).webclient(any(OAuth2AuthorizedClientManager.class)).thenReturn(Webclient.builder.build);
Aucun commentaire:
Enregistrer un commentaire