### Question:
DebugInfoBody implements DebugInfo { @Override public void appendJson(final JsonStreamWriter jsonStreamWriter) throws IOException { if (isJson) { jsonStreamWriter.unquotedValue(getContentString()); } else if (isText) { jsonStreamWriter.stringValue(getContentString()); } else { jsonStreamWriter.stringValueRaw(getContentString()); } } DebugInfoBody(final ODataResponse response, final String serviceRoot); @Override String getName(); @Override void appendJson(final JsonStreamWriter jsonStreamWriter); @Override void appendHtml(final Writer writer);  }### Answer:
@Test public void jsonStringContent() throws Exception { ODataResponse response = mock(ODataResponse.class); when(response.getEntity()).thenReturn(STRING_CONTENT); when(response.getContentHeader()).thenReturn(HttpContentType.APPLICATION_OCTET_STREAM); assertEquals(STRING_CONTENT_JSON, appendJson(response)); when(response.getContentHeader()).thenReturn("image/png"); assertEquals(STRING_CONTENT_JSON, appendJson(response)); }
@Test public void jsonInputStreamContent() throws Exception { ODataResponse response = mock(ODataResponse.class); ByteArrayInputStream in = new ByteArrayInputStream(STRING_CONTENT.getBytes()); when(response.getEntity()).thenReturn(in); when(response.getContentHeader()).thenReturn(HttpContentType.TEXT_PLAIN); assertEquals(STRING_CONTENT_JSON, appendJson(response)); in = new ByteArrayInputStream(STRING_CONTENT.getBytes("UTF-8")); when(response.getEntity()).thenReturn(in); when(response.getContentHeader()).thenReturn("image/png"); assertEquals("\"" + Base64.encodeBase64String(STRING_CONTENT.getBytes("UTF-8")) + "\"", appendJson(response)); }
@Test(expected = ClassCastException.class) public void jsonUnsupportedContent() throws Exception { ODataResponse response = mock(ODataResponse.class); when(response.getEntity()).thenReturn(new Object()); when(response.getContentHeader()).thenReturn(HttpContentType.APPLICATION_OCTET_STREAM); appendJson(response); }