<legend id='FLf5g'><style id='FLf5g'><dir id='FLf5g'><q id='FLf5g'></q></dir></style></legend>
<tfoot id='FLf5g'></tfoot>
    <i id='FLf5g'><tr id='FLf5g'><dt id='FLf5g'><q id='FLf5g'><span id='FLf5g'><b id='FLf5g'><form id='FLf5g'><ins id='FLf5g'></ins><ul id='FLf5g'></ul><sub id='FLf5g'></sub></form><legend id='FLf5g'></legend><bdo id='FLf5g'><pre id='FLf5g'><center id='FLf5g'></center></pre></bdo></b><th id='FLf5g'></th></span></q></dt></tr></i><div id='FLf5g'><tfoot id='FLf5g'></tfoot><dl id='FLf5g'><fieldset id='FLf5g'></fieldset></dl></div>

    <small id='FLf5g'></small><noframes id='FLf5g'>

          <bdo id='FLf5g'></bdo><ul id='FLf5g'></ul>

        Mockito 模拟 restTemplate.postForEntity

        时间:2023-09-26
        <tfoot id='nZJyz'></tfoot>
      1. <small id='nZJyz'></small><noframes id='nZJyz'>

          <tbody id='nZJyz'></tbody>

        • <i id='nZJyz'><tr id='nZJyz'><dt id='nZJyz'><q id='nZJyz'><span id='nZJyz'><b id='nZJyz'><form id='nZJyz'><ins id='nZJyz'></ins><ul id='nZJyz'></ul><sub id='nZJyz'></sub></form><legend id='nZJyz'></legend><bdo id='nZJyz'><pre id='nZJyz'><center id='nZJyz'></center></pre></bdo></b><th id='nZJyz'></th></span></q></dt></tr></i><div id='nZJyz'><tfoot id='nZJyz'></tfoot><dl id='nZJyz'><fieldset id='nZJyz'></fieldset></dl></div>
            <bdo id='nZJyz'></bdo><ul id='nZJyz'></ul>

              <legend id='nZJyz'><style id='nZJyz'><dir id='nZJyz'><q id='nZJyz'></q></dir></style></legend>
                1. 本文介绍了Mockito 模拟 restTemplate.postForEntity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试模拟 restTemplate.postForEntity 方法,

                  I am trying to mock restTemplate.postForEntity method,

                  实际的方法调用是:

                  URI myUri = new URI(myString);
                  HttpEntity<String> myEntity ...
                  
                  
                  String myResponse = restTemplate.postForEntity(myUri, myEntity, String.class);
                  

                  我的测试课是:

                  Mockito.when(restTemplate.postForEntity(any(URI.class), any(HttpEntity.class), eq(String.class))).thenReturn(response);
                  

                  这不起作用;我尝试了其他几种排列也没有成功.任何建议表示赞赏,谢谢.

                  This does not work; I have tried several other permutations with no success either. Any suggestions appreciated, thanks.

                  这不起作用我的意思是调用实际方法而不是模拟方法(因此不返回所需的结果等)

                  By this does not work I mean that the actual method is called and not the mocked method (so the desired result is not returned etc.)

                  推荐答案

                  以下代码对我有用 -when(mockRestTemplate.postForEntity(anyString(), any(), eq(String.class))).thenReturn(response);

                  这篇关于Mockito 模拟 restTemplate.postForEntity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 String 和 class 作为参数为 EntityManger cr 下一篇:通缉但不调用:Mockito PrintWriter

                  相关文章

                  最新文章

                  <tfoot id='R7JdD'></tfoot>

                  <legend id='R7JdD'><style id='R7JdD'><dir id='R7JdD'><q id='R7JdD'></q></dir></style></legend>

                2. <small id='R7JdD'></small><noframes id='R7JdD'>

                      • <bdo id='R7JdD'></bdo><ul id='R7JdD'></ul>
                      <i id='R7JdD'><tr id='R7JdD'><dt id='R7JdD'><q id='R7JdD'><span id='R7JdD'><b id='R7JdD'><form id='R7JdD'><ins id='R7JdD'></ins><ul id='R7JdD'></ul><sub id='R7JdD'></sub></form><legend id='R7JdD'></legend><bdo id='R7JdD'><pre id='R7JdD'><center id='R7JdD'></center></pre></bdo></b><th id='R7JdD'></th></span></q></dt></tr></i><div id='R7JdD'><tfoot id='R7JdD'></tfoot><dl id='R7JdD'><fieldset id='R7JdD'></fieldset></dl></div>