### Question:
AuthorizedRequest extends BaseRequest<JSONObject, AuthorizationException> { @Override public JSONObject executeRequest(OktaHttpClient client) throws AuthorizationException { AuthorizationException exception = null; HttpResponse response = null; try { response = openConnection(client); return response.asJson(); } catch (IOException io) { exception = new AuthorizationException(io.getMessage(), io); } catch (JSONException je) { exception = AuthorizationException.fromTemplate(AuthorizationException .GeneralErrors.JSON_DESERIALIZATION_ERROR, je); } catch (Exception e) { exception = AuthorizationException.fromTemplate(AuthorizationException .GeneralErrors.NETWORK_ERROR, e); } finally { if (response != null) { response.disconnect(); } if (exception != null) { throw exception; } } return null; } AuthorizedRequest(HttpRequestBuilder.Authorized b); @Override JSONObject executeRequest(OktaHttpClient client);  }### Answer:
@Test public void executeRequestSuccess() throws AuthorizationException, JSONException { mEndPoint.enqueueUserInfoSuccess(); JSONObject json = mRequest.executeRequest(mHttpClient); assertNotNull(json); assertEquals(json.getString("nickname"), "Jimmy"); }
@Test public void executeRequestFailure() throws AuthorizationException { mExpectedEx.expect(AuthorizationException.class); mExpectedEx.expectMessage("Invalid status code 401 Client Error"); mEndPoint.enqueueReturnInvalidClient(); mRequest.executeRequest(mHttpClient); }
@Test public void executeRequestSuccessWithOkHttp() throws AuthorizationException, JSONException { mEndPoint.enqueueUserInfoSuccess(); JSONObject json = mRequest.executeRequest(new OkHttp()); assertNotNull(json); assertEquals(json.getString("nickname"), "Jimmy"); }
@Test public void executeRequestFailureWithOkHttp() throws AuthorizationException { mExpectedEx.expect(AuthorizationException.class); mExpectedEx.expectMessage("Invalid status code 401 Client Error"); mEndPoint.enqueueReturnInvalidClient(); mRequest.executeRequest(new OkHttp()); }