代码:
public class AccountService(){
private ObjectMapper mapper = new ObjectMapper();
public Account getAccount(){
try {
ClientResponse response = RestUtility.getAccounts();
if(CLientResponse.OK.Status == response.getClientResponseStatus()){
return mapper.readValue(response.getEntity(String.class), Account.class)
}
} catch(Exception e){
log.error(e.getMessage(), e);
}
return null;
}
}
我怎样才能模拟这项服务?RestUtility 是一个静态实用程序,不能被 mockito 模拟。我想要的只是让我的方法返回一个“模拟”帐户列表。这种架构甚至可能吗?