코드 :Mockito 및 JUnit을
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에 의해 조롱 될 수 없습니다. 내가 원하는 것은 '모의'계정 목록을 반환하는 나의 방법입니다. 이 아키텍처로도 가능합니까?
사용 PowerMock https://code.google.com/p/powermock/wiki/MockitoUsage –