@RequestMapping(value = "/agreementRecords/{customerId}", method = RequestMethod.GET)
public List<AgreementRecord> agreementRecords(@PathVariable("customerId") String customerId) throws AgreementRecordNotFoundException{
logger.info("Inside get Agreement Records by customer Id");
try{
ResponseEntity<List<AgreementRecord>> responseEntity = restTemplate.exchange(smoUrl+ GET_AGREEMENT_RECORDS + customerId ,HttpMethod.GET,null,new ParameterizedTypeReference<List<AgreementRecord>>() {
});
return responseEntity.getBody();
如何模拟此服务,我尝试了以下方法
ResponseEntity<List<AgreementRecord>> myEntity = new ResponseEntity<List<AgreementRecord>>(HttpStatus.ACCEPTED);
PowerMockito.when(restTemplate.exchange(
ArgumentMatchers.anyString(),
ArgumentMatchers.any(HttpMethod.class),
ArgumentMatchers.<HttpEntity<?>>any(),
ArgumentMatchers.<Class<?>>any())).thenReturn(myEntity);
但是这会引发编译错误enter image description here