@Test public void dispatch_shouldCallOnFailureWhenApiResponseIsFailure() throws Exception { XmlApiResponse apiResponse = new XmlApiResponse(500); apiGateway.dispatch(apiResponse, responseCallbacks); assertThat(responseCallbacks.failureResponse, sameInstance((ApiResponse) apiResponse)); assertThat(responseCallbacks.successResponse, nullValue()); assertThat(responseCallbacks.onCompleteWasCalled, equalTo(true)); }
protected void dispatch(ApiResponse apiResponse, ApiResponseCallbacks responseCallbacks) { if (apiResponse.isSuccess()) { try { responseCallbacks.onSuccess(apiResponse); } catch (Exception e) { Log.e(ApiGateway.class.getName(), "Error proccessing response", e); responseCallbacks.onFailure(apiResponse); } } else { responseCallbacks.onFailure(apiResponse); } responseCallbacks.onComplete(); }
ApiGateway { protected void dispatch(ApiResponse apiResponse, ApiResponseCallbacks responseCallbacks) { if (apiResponse.isSuccess()) { try { responseCallbacks.onSuccess(apiResponse); } catch (Exception e) { Log.e(ApiGateway.class.getName(), "Error proccessing response", e); responseCallbacks.onFailure(apiResponse); } } else { responseCallbacks.onFailure(apiResponse); } responseCallbacks.onComplete(); } }
ApiGateway { protected void dispatch(ApiResponse apiResponse, ApiResponseCallbacks responseCallbacks) { if (apiResponse.isSuccess()) { try { responseCallbacks.onSuccess(apiResponse); } catch (Exception e) { Log.e(ApiGateway.class.getName(), "Error proccessing response", e); responseCallbacks.onFailure(apiResponse); } } else { responseCallbacks.onFailure(apiResponse); } responseCallbacks.onComplete(); }  }
ApiGateway { protected void dispatch(ApiResponse apiResponse, ApiResponseCallbacks responseCallbacks) { if (apiResponse.isSuccess()) { try { responseCallbacks.onSuccess(apiResponse); } catch (Exception e) { Log.e(ApiGateway.class.getName(), "Error proccessing response", e); responseCallbacks.onFailure(apiResponse); } } else { responseCallbacks.onFailure(apiResponse); } responseCallbacks.onComplete(); }  void makeRequest(ApiRequest<T> apiRequest, final ApiResponseCallbacks<T> responseCallbacks); }
ApiGateway { protected void dispatch(ApiResponse apiResponse, ApiResponseCallbacks responseCallbacks) { if (apiResponse.isSuccess()) { try { responseCallbacks.onSuccess(apiResponse); } catch (Exception e) { Log.e(ApiGateway.class.getName(), "Error proccessing response", e); responseCallbacks.onFailure(apiResponse); } } else { responseCallbacks.onFailure(apiResponse); } responseCallbacks.onComplete(); }  void makeRequest(ApiRequest<T> apiRequest, final ApiResponseCallbacks<T> responseCallbacks);  }