Mockito如何测试匿名内部类方法?

时间:2019-11-08 08:56:40

标签: java spring-boot junit mockito powermockito

在下面的类中,我有匿名的内部类,因此如何使用嘲讽对其进行测试。请检查以下代码

// Service class
@Component("someServiceClass")
public class SomeServiceClassImpl implements SomeServiceClass {

 @Autowired
 RepoClass repo;

 LoadingCache < String, ClientDetails > clientDetailsCache = 
CacheBuilder.newBuilder()
  .build(new CacheLoader < String, ClientDetails > () {
   @Override
   public ClientDetails load(String clientId) throws Exception {

    OauthClientMapping client = repo.findByClientId(clientId);

    return someObject;
   }
  });

 @Override
 public void method(String id) {
  String param = request.getParameter("param");
 }
}

0 个答案:

没有答案