无法模拟RestTemplate.exchange类。获取RestTemplate不适用于参数错误

时间:2019-01-29 06:37:33

标签: junit mockito

我正在尝试模拟restTeamplate.exchange方法,但是在尝试模拟时出现以下错误 RestTemplate类型的方法exchange(String,HttpMethod,HttpEntity,Class,Object ...)不适用于参数(String,HttpMethod,HttpEntity,Object)

Mockito.when(restTemplate.exchange(
            Matchers.anyString(),
            Matchers.any(HttpMethod.class),
            Matchers.<HttpEntity<?>> any(), 
            Matchers.<Object> any())
        ).thenReturn(myResponse);

1 个答案:

答案 0 :(得分:0)

我解决了,但更换了     Matchers.<Object> any() 与     Matchers.<Class<responseClassName>> any()

相关问题