What is the proper way of mocking external API call inside my RestController
.
Meaning my RestController
actually does these steps:
- transformation on date
- call external API with the data
- respond with the external API response
Can't copy/paste because of security issues but in general:
@RestController
public Class x{
RestTemplate y = new RestTemplate();
@RequestMapping(value="/someurl" , method=RequestMethod=POST)
public String myMethod(@RequestBody JsonNode myjson)
{
//business logic
ResponseEntity<String> response = restTemplate.exchange(url,HttpMethod,
internalRequest,String.class);
return response.getBody()
}