Using Mockito, how do I match against the key-value pair of a map?

后端 未结 4 1152
清酒与你
清酒与你 2021-02-12 11:50

I need to send a specific value from a mock object based on a specific key value.

From the concrete class:

map.put(\"xpath\", \"PRICE\");
search(map);
         


        
4条回答
  •  滥情空心
    2021-02-12 12:09

    Doesn't this work?

    Map map = new HashMap();
    map.put("xpath", "PRICE");
    when(mock.search(map)).thenReturn("$100.00");
    

    The Map parameter should behave the same way as other parameters.

提交回复
热议问题