【问题标题】:Unable to Mock RestTemplate.exchange class..getting RestTemplate not application for arguments error无法模拟 RestTemplate.exchange class..getting RestTemplate not application for arguments 错误
【发布时间】:2019-06-22 05:37:36
【问题描述】:

我正在尝试模拟 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);

【问题讨论】:

    标签: junit mockito


    【解决方案1】:

    我解决了,但更换了 Matchers.&lt;Object&gt; any()Matchers.&lt;Class&lt;responseClassName&gt;&gt; any().

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-13
      • 1970-01-01
      • 1970-01-01
      • 2019-09-22
      • 1970-01-01
      相关资源
      最近更新 更多