ServletResponseResultWriter implements ResultWriter { @Override public void write(Object response) throws IOException { if (response == null) { write(HttpServletResponse.SC_NO_CONTENT, null, null); } else { write(HttpServletResponse.SC_OK, null, ResponseUtil.wrapCollection(response)); } } ServletResponseResultWriter(
      HttpServletResponse servletResponse, ApiSerializationConfig serializationConfig);  ServletResponseResultWriter(
      HttpServletResponse servletResponse, ApiSerializationConfig serializationConfig,
      boolean prettyPrint, boolean addContentLength); @Override void write(Object response); @Override void writeError(ServiceException e);  }
@Test public void testWriteNull() throws Exception { MockHttpServletResponse response = new MockHttpServletResponse(); ServletResponseResultWriter writer = new ServletResponseResultWriter(response, null); writer.write(null); assertEquals("", response.getContentAsString()); assertEquals(HttpServletResponse.SC_NO_CONTENT, response.getStatus()); }
@Test public void testPrettyPrint() throws Exception { MockHttpServletResponse response = new MockHttpServletResponse(); ServletResponseResultWriter writer = new ServletResponseResultWriter(response, null, true , true ); writer.write(ImmutableMap.of("one", "two", "three", "four")); String body = response.getContentAsString(); int index = body.indexOf('\n'); assertThat(index).isAtLeast(0); index = body.indexOf('\n', index + 1); assertThat(index).isAtLeast(0); assertThat(body).contains("\": "); assertThat(body).doesNotContain("\" :"); }