如何使用Mockito为Restcall代理方法编写JUnit

时间:2018-07-27 11:03:43

标签: java junit mockito

嗨,我有一个方法并将结果作为地图返回。

public @ResponseBody Map<String, Object>getDetails(HttpServletRequest request, CustomRequest request){
Map<String, Object> result = (Map<String, Object>) restAgent.post(getRequestMapping(request), customRequest, Map.class);
return result;
}

and i have return junit for this method using mockito framework.

public void testGetDetails(){
when(restAgent.post(eq(Mockito.anyString(), eq(customRequest), Map.class).thenReturn(new HashMap());
getDetails(request, customRequest)// after executing this getting result is null
}

我得到空结果。

如何模拟getDetails方法

0 个答案:

没有答案