How can I mock webClient in my unit test for the class below
@Service
public class Service {
private final WebClient webClient;
public Service(String baseUrl) {
this.webClient = WebClient.builder().baseUrl(baseUrl).build();
}
public User getUser() { webClient.get().bodyToMono(User.class).block(); }
}
- ReflectionTestUtils works, is there a better way?
- No constructor injection of WebClient
Service(WebClient webClient)
Any solutions?