【发布时间】:2019-03-26 12:25:29
【问题描述】:
我正在尝试使用以下代码模拟 RestTemplate exchange() 调用:
测试方法
given(restTemplate.exchange(any(UriComponents.class), any(HttpMethod.class), any(HttpEntity.class), any(StatusResponse.class)))
.willReturn(new ResponseEntity<>(HttpStatus.BAD_GATEWAY));
代码无法编译,因为:
- 它抱怨
cannot resolve method willReturn(new ResponseEntity<>(HttpStatus.BAD_GATEWAY)) - 它抱怨
cannot resolve method exchange(T, T, T, T)
我应该如何更改签名以使其正常工作?谢谢。
【问题讨论】:
标签: spring mockito bdd resttemplate