具有Spring Rest模板的Powermockito是正确的方式

时间:2018-06-13 17:01:44

标签: powermockito

我正在尝试在下面粘贴的callRestService函数中使用Powermockito。在正确的方法上做任何可能的指示?

 public RestResponse callRestService(RestRequest request) {

 HttpHeaders headers = new HttpHeaders();
 headers.setAccept(Arrays.asList(new MediaType[] { MediaType.APPLICATION_JSON }));
 headers.setContentType(MediaType.APPLICATION_JSON);

 HttpEntity<RestRequest> entityReq = new HttpEntity<RestRequest>(
      request, headers);

 RestTemplate template = new RestTemplate();

 ResponseEntity<RestResponse> respEntity = template.
      exchange("RestSvcUrl", HttpMethod.POST, entityReq, RestResponse.class);

 return respEntity.getBody();
}

0 个答案:

没有答案