How to fix the null value response of RestTemplate.exchange in a Mockito Test?
问题 My Service class is below, followed by its test - @Service public class MyServiceImpl implements MyService { @Autowired private RestTemplate restTemplate; @Override public StudentInfo getStudentInfo(String name) { HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); HttpEntity entity = new HttpEntity(headers); StudentInfo student = null; URI uri = new URI("http:\\someurl.com"); ResponseEntity<String> responseEntity = restTemplate.exchange(uri,