@Test public void error() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ResponseWriter writer = new ResponseWriter(out); Response response; response = new Response(); response.status = "fatal"; response.errors = new ArrayList<>(); response.errors.add("error"); writer.write(response); final String result = new String(out.toByteArray()); final String expected = "{\"status\":\"fatal\",\"errors\":[\"error\"]}\n"; assertThat(result).isEqualTo(expected); }
public void write(final Response response) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, response); out.write('\n'); this.out.write(out.toByteArray()); }
ResponseWriter { public void write(final Response response) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, response); out.write('\n'); this.out.write(out.toByteArray()); } }
ResponseWriter { public void write(final Response response) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, response); out.write('\n'); this.out.write(out.toByteArray()); } ResponseWriter(final OutputStream out); }
ResponseWriter { public void write(final Response response) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, response); out.write('\n'); this.out.write(out.toByteArray()); } ResponseWriter(final OutputStream out); void setContent(String content); void write(final Response response); }
ResponseWriter { public void write(final Response response) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); mapper.writeValue(out, response); out.write('\n'); this.out.write(out.toByteArray()); } ResponseWriter(final OutputStream out); void setContent(String content); void write(final Response response);  }