### Question:
BaseRequestHandler extends MinimalRequestHandler { protected void respondWithJson(final HttpServletResponse response, final JSONObject jsonObject) { configureResponse(ResponseTypes.JSON_OBJECT, response, jsonObject); } protected  BaseRequestHandler(UserRepository userRepository, WorkspaceRepository workspaceRepository, Configuration configuration); @Override abstract void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain); static void setMaxAge(final HttpServletResponse response, int numberOfSeconds); static String generateETag(byte[] data); static void addETagHeader(final HttpServletResponse response, String eTag); boolean testEtagHeaders(HttpServletRequest request, HttpServletResponse response, String eTag); UserRepository getUserRepository(); WorkspaceRepository getWorkspaceRepository(); ObjectMapper getObjectMapper();  }### Answer:
@Test(expected = NullPointerException.class) public void testRespondWithJsonObjectInvalidResponse() { mock.respondWithJson(null, JSON_OBJECT); }
@Test(expected = NullPointerException.class) public void testRespondWithJsonObjectInvalidJsonObject() { mock.respondWithJson(response, (JSONObject)null); }
@Test public void testRespondWithJsonObject() throws IOException { when(response.getWriter()).thenReturn(writer); mock.respondWithJson(response, JSON_OBJECT); }
@Test(expected = NullPointerException.class) public void testRespondWithJsonArrayInvalidResponse() { mock.respondWithJson(null, JSON_ARRAY); }
@Test(expected = NullPointerException.class) public void testRespondWithJsonArrayInvalidJsonArray() { mock.respondWithJson(response, (JSONArray)null); }
@Test public void testRespondWithJsonArray() throws IOException { when(response.getWriter()).thenReturn(writer); mock.respondWithJson(response, JSON_ARRAY); }
@Test(expected = RuntimeException.class) public void testRespondWithJsonWriterException() throws IOException { when(response.getWriter()).thenThrow(new IOException()); mock.respondWithJson(response, JSON_OBJECT); }