Not able to use mocked restTemplate twice

54 Views Asked by At

I am not able to use mocked restTemplate twice when calling an api with two different request bodies to have two corresponding responses, it’s giving suggestion like check the arguments for mocked resttemplate call. But when I call it for one time it works

when(dlfRestTemplate.postForObject(“url” , requestBody1, ResponseBdy.class)).thenReturn(response1) when(dlfRestTemplate.postForObject(“url” , requestBody2, ResponseBdy.class)).thenReturn(response2)

This is how I want to use rest template to mock the api call with two different request bodies.

0

There are 0 best solutions below