TokenUpdateHandler extends AsyncHttpResponseHandler { @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { String log = "[token update] Received status " + statusCode; String responseBodyString; if (responseBody != null) { responseBodyString = new String(responseBody); log += " with: " + responseBodyString; } else { responseBodyString = "[no body]"; } Log.e(TAG, log); if (statusCode == 404) { this.invalidClientIdHandler.onInvalidClientId(retryParams); } else { listenerStack.onFailedRegistration(statusCode, responseBodyString); } } TokenUpdateHandler(String cachedId, StringEntity retryParams, Context context, RegistrationListenerStack listenerStack, InvalidClientIdHandler invalidClientIdHandler); @Override void onSuccess(int statusCode, Header[] headers, byte[] responseBody); @Override void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error);  }
@Test public void testListenerStackFailureOnNon404(){ tokenUpdateHandler.onFailure(500, null, null, null); verify(listenerStack).onFailedRegistration(500, "[no body]"); }
@Test public void testCallsOnInvalidClientIdOn404() { tokenUpdateHandler.onFailure(404, null, null, null); verify(invalidClientIdHandler).onInvalidClientId(params); }