伪客户端模拟响应返回null

时间:2020-04-16 09:02:08

标签: mockito openfeint

我正在使用Mockito进行单元测试。但是当我尝试调用假客户端时,它总是返回null而不是模拟对象。

高级客户

 @FeignClient(url = "${Users.details}",name = "userDetails")
 public interface UserDetails {
    public Object getUserDetails(@RequestHeader Map<String, Object> headers, @RequestParam Map<String, 
 Object> requestParams);
 }

测试方法

@InjectMocks UserServices userServices;
@Mock UserServicesRest userServicesRest;
Object mockUserDetails = "UserDetails Data";

 @Test
 public void driverData() {
Mockito.when(userServicesRest.getUserDetails(Mockito.anyMap(),Mockito.anyMap())).thenReturn(mockUserDetails);
}   

请提前帮助谢谢。

0 个答案:

没有答案