@Test
public void testPrettyPrint() throws Exception {

  MockHttpServletResponse response = new MockHttpServletResponse();
  ServletResponseResultWriter writer = new ServletResponseResultWriter(response, null,
      true /* prettyPrint */, true /* addContentLength */);
  writer.write(ImmutableMap.of("one", "two", "three", "four"));
  // If the response is pretty printed, there should be at least two newlines.
  String body = response.getContentAsString();
  int index = body.indexOf('\n');
  assertThat(index).isAtLeast(0);
  index = body.indexOf('\n', index + 1);
  assertThat(index).isAtLeast(0);
  // Unlike the Jackson pretty printer, which will either put no space around a colon or a space
  // on both sides, we want to ensure that a space comes after a colon, but not before.
  assertThat(body).contains("\": ");
  assertThat(body).doesNotContain("\" :");
}