### Question:
HttpObjectClient implements ObjectClient<T> { protected DataObjectResponse<T> buildExceptionResponse(IOException e, String message, HttpURLConnection urlConnection) { String responseMessage = null; int responseCode = 400; try { responseMessage = urlConnection.getResponseMessage(); responseCode = urlConnection.getResponseCode(); } catch (IOException | NullPointerException e2) { logger.debug("Failed to get responseCode from HttpURLConnection. Using default.", e2); } if(responseMessage == null) responseMessage = DEFAULT_RESPONSE_MESSAGE; return new DefaultDataObjectResponse<>(ErrorResponseFactory.buildErrorResponse( new ObjectClientException(String.join(" :: ", responseMessage, message), e), responseCode, MDC.get("CID"))); } HttpObjectClient(String endpointURL, HttpURLConnectionFactory httpUrlConnectionFactory, Class<T> clazz); DataObjectResponse<T> getObjects(String queryParams); DataObjectResponse<T> getObjects(List<Query> queries); DataObjectResponse<T> getObject(String id); DataObjectResponse<T> persistObject(T object); DataObjectResponse<T> updateObject(T object, String id); DataObjectResponse<T> deleteObject(String id); Class<T> getObjectClass(); void setUrlRequestPerformer(URLRequestPerformer urlRequestPerformer); final static String DEFAULT_RESPONSE_MESSAGE; }### Answer:
@Test(dataProvider = "buildExceptionResponseProvider") public void testBuildExceptionResponse(HttpURLConnection connection, String expectedMessage) throws IOException { final IOException e = new IOException(); DataObjectResponse<AgendaProgress> dataObjectResponse = client.buildExceptionResponse(e, HTTP_RESPONSE_MESSAGE, connection); Assert.assertNotNull(dataObjectResponse.getErrorResponse()); Assert.assertTrue(dataObjectResponse.isError()); ErrorResponse errorResponse = dataObjectResponse.getErrorResponse(); Assert.assertEquals(errorResponse.getTitle(), ObjectClientException.class.getSimpleName()); Assert.assertTrue(errorResponse.getServerStackTrace().startsWith(e.getClass().getName()), "StackTrace should have the prefix: " + e.getClass().getName()); Assert.assertEquals(errorResponse.getResponseCode(), (Integer)connection.getResponseCode()); Assert.assertEquals(errorResponse.getDescription(), expectedMessage); }