JsonFormatter extends AbstractFormatter { @Override public void write(final Datenpaket datenpaket) throws IOException { String value = OBJECT_MAPPER.writeValueAsString(datenpaket); this.write(value); } JsonFormatter();  JsonFormatter(final OutputStream ostream);  JsonFormatter(final Writer writer); @Override void write(final Datenpaket datenpaket);  }
@Test public void testWriteDatenpaket() throws IOException { try (StringWriter swriter = new StringWriter()) { JsonFormatter formatter = new JsonFormatter(swriter); formatter.write(new Datenpaket()); swriter.flush(); String jsonString = swriter.toString().trim(); LOG.info("jsonString = '{}'", jsonString); assertThat(jsonString, startsWith("{")); } }