Test with MockWebServer
Let’s learn to use the WebClient to access the third-party APIs and test the code by using the MockWebServer.
We'll cover the following...
We'll cover the following...
The WebClient
class
Spring recommends using the WebClient
class instead of RestTemplate
for accessing the third-party APIs, because WebClient
provides a non-blocking reactive client over the underlying HTTP client.
Setup
First, let’s add Spring Boot’s spring-boot-starter-webflux
dependency, which incorporates the WebClient
...