ApiDownInterceptor implements Interceptor { public static Builder create() { return new Builder(); } private  ApiDownInterceptor(ApiDownChecker apiDownChecker); @Override Response intercept(Chain chain); static Builder create();  }
@Test(expected = ApiDownException.class) public void default_interceptor_throws_exception_when_request_unsuccessful_if_api_down() throws Exception { ApiDownInterceptor interceptor = ApiDownChecker.create() .check(BROKEN_API_URL) .trust(WORKING_API_URL) .buildInterceptor(); executeUnsuccessfulRequest(interceptor); }
@Test public void default_interceptor_doesnt_throw_exception_when_request_unsuccessful_if_api_up() throws Exception { ApiDownInterceptor interceptor = ApiDownChecker.create() .check(WORKING_API_URL) .trust(WORKING_API_URL) .buildInterceptor(); executeUnsuccessfulRequest(interceptor); }
@Test public void default_interceptor_doesnt_throw_exception_when_request_successful() throws Exception { ApiDownInterceptor interceptor = ApiDownChecker.create() .check(WORKING_API_URL) .trust(WORKING_API_URL) .buildInterceptor(); executeWorkingRequest(interceptor); }
@Test(expected = ApiDownException.class) public void default_interceptor_throws_exception_when_request_fails_if_api_down() throws Exception { ApiDownInterceptor interceptor = ApiDownChecker.create() .check(BROKEN_API_URL) .trust(WORKING_API_URL) .buildInterceptor(); executeFailingRequest(interceptor); }