This sample shows, how a service which depends on an external API can be tested in isolation by mocking the remote server.
- The
RestExchangeServiceconverts from one currency to another. - Exchange rates are retrieved from https://exchangeratesapi.io/ using a
RestTemplate. - The
ExchangeControllerprovides the conversion as REST API. - The
RestExchangeServiceTestmocks the REST API used to get the exchange rates.