@Test public void enqueue_CallsDelegateMethodWithNonNullArgument() throws Exception { testCall.enqueue(testCallback); verify(mockOkHttpCall).enqueue(callbackArgumentCaptor.capture()); okhttp3.Callback passedCallback = callbackArgumentCaptor.getValue(); assertNotNull(passedCallback); }
@Override public void enqueue(final Callback<T> callback) { if (callback == null) { throw new IllegalArgumentException("Callback argument cannot be null."); } rawCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(OkHttpCall.this, e); } @Override public void onResponse(okhttp3.Call call, Response response) throws IOException { try { callback.onResponse(OkHttpCall.this, adapt(response)); } catch (ApiError | IOException e) { closeQuietly(response); callback.onFailure(OkHttpCall.this, e); } } }); }
OkHttpCall implements Call<T> { @Override public void enqueue(final Callback<T> callback) { if (callback == null) { throw new IllegalArgumentException("Callback argument cannot be null."); } rawCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(OkHttpCall.this, e); } @Override public void onResponse(okhttp3.Call call, Response response) throws IOException { try { callback.onResponse(OkHttpCall.this, adapt(response)); } catch (ApiError | IOException e) { closeQuietly(response); callback.onFailure(OkHttpCall.this, e); } } }); } }
OkHttpCall implements Call<T> { @Override public void enqueue(final Callback<T> callback) { if (callback == null) { throw new IllegalArgumentException("Callback argument cannot be null."); } rawCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(OkHttpCall.this, e); } @Override public void onResponse(okhttp3.Call call, Response response) throws IOException { try { callback.onResponse(OkHttpCall.this, adapt(response)); } catch (ApiError | IOException e) { closeQuietly(response); callback.onFailure(OkHttpCall.this, e); } } }); } OkHttpCall(okhttp3.Call rawCall, ResponseAdapter<T> adapter); }
OkHttpCall implements Call<T> { @Override public void enqueue(final Callback<T> callback) { if (callback == null) { throw new IllegalArgumentException("Callback argument cannot be null."); } rawCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(OkHttpCall.this, e); } @Override public void onResponse(okhttp3.Call call, Response response) throws IOException { try { callback.onResponse(OkHttpCall.this, adapt(response)); } catch (ApiError | IOException e) { closeQuietly(response); callback.onFailure(OkHttpCall.this, e); } } }); } OkHttpCall(okhttp3.Call rawCall, ResponseAdapter<T> adapter); @Override T execute(); @Override void enqueue(final Callback<T> callback); @Override boolean isExecuted(); @Override void cancel(); @Override boolean isCanceled(); @SuppressWarnings("CloneDoesntCallSuperClone") @Override OkHttpCall<T> clone(); }
OkHttpCall implements Call<T> { @Override public void enqueue(final Callback<T> callback) { if (callback == null) { throw new IllegalArgumentException("Callback argument cannot be null."); } rawCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(okhttp3.Call call, IOException e) { callback.onFailure(OkHttpCall.this, e); } @Override public void onResponse(okhttp3.Call call, Response response) throws IOException { try { callback.onResponse(OkHttpCall.this, adapt(response)); } catch (ApiError | IOException e) { closeQuietly(response); callback.onFailure(OkHttpCall.this, e); } } }); } OkHttpCall(okhttp3.Call rawCall, ResponseAdapter<T> adapter); @Override T execute(); @Override void enqueue(final Callback<T> callback); @Override boolean isExecuted(); @Override void cancel(); @Override boolean isCanceled(); @SuppressWarnings("CloneDoesntCallSuperClone") @Override OkHttpCall<T> clone();  }