TokenUploadHandler extends JsonHttpResponseHandler { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { String clientId = response.getString("id"); Log.d(TAG, "Uploaded registration token and received id: " + clientId); this.listenerStack.onSuccessfulRegistration(clientId, context); } catch (JSONException e) { e.printStackTrace(); } } TokenUploadHandler(Context context, RegistrationListenerStack listenerStack); @Override void onSuccess(int statusCode, Header[] headers, JSONObject response); @Override void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse); @Override void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable);  }
@Test public void onSuccess() throws Exception { JSONObject response = new JSONObject(); response.put("id", "new-client-id"); uploadHandler.onSuccess(200, null, response); verify(stack).onSuccessfulRegistration("new-client-id", context); }