following is my method which I am trying to unit test
public class Emp {
public String getName() {
ResponseEntity<LinkedHashMap> res = restTemplate.postForEntity(url, null, LinkedHashMap.class);
return res.getBody().get("name");
}
}
My unit test code is as follows
LinkedHashMap<String, String> map = new LinkedHashMap<>();
map.put("name", "foo");
ResponseEntity<LinkedHashMap> entity = new ResponseEntity<>(map, HttpStatus.OK);
Mockito.when(restTemplate.postForEntity(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(entity);
But I am getting compilation error as
java: no suitable method found for thenReturn(org.springframework.http.ResponseEntity<java.util.LinkedHashMap>)
Couldn't get rid of the error after many trial n error.
Can someone point at whats wrong here and how I can fix the unit test code?
thanks