How do i mock RestTemplate exchange
问题 Trying the mocking as below : Mockito.doReturn(responseEntity).when(restTemplate.exchange(anyString(), anyObject(), anyObject(), anyObject())); this gave me a compilation issue: "The method exchange(String, HttpMethod, HttpEntity, Class, Object[]) is ambiguous for the type RestTemplate" so tried : GetRelationshipInfoResponse relationship = getEntity(); ResponseEntity<GetRelationshipInfoResponse> responseEntity = new ResponseEntity<GetRelationshipInfoResponse>(relationship, HttpStatus.ACCEPTED