@Test public void testPrint() throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream out = new PrintStream(baos); new EventPrinter(out, false).accept(event()); String result = baos.toString("utf-8"); assertThat(result, equalTo("2016-01-01 12:00:00 - myTopic\n")); }
@Override public void accept(Event event) { out.println(getTimeStamp(event) + " - " + event.getTopic()); if (verbose) { for (String key : event.getPropertyNames()) { if (!key.equals("event.topics") && !key.equals("timestamp")) { out.println(key + ": " + getPrintValue(event, key)); } } out.println(); out.flush(); } }
EventPrinter implements Consumer<Event> { @Override public void accept(Event event) { out.println(getTimeStamp(event) + " - " + event.getTopic()); if (verbose) { for (String key : event.getPropertyNames()) { if (!key.equals("event.topics") && !key.equals("timestamp")) { out.println(key + ": " + getPrintValue(event, key)); } } out.println(); out.flush(); } } }
EventPrinter implements Consumer<Event> { @Override public void accept(Event event) { out.println(getTimeStamp(event) + " - " + event.getTopic()); if (verbose) { for (String key : event.getPropertyNames()) { if (!key.equals("event.topics") && !key.equals("timestamp")) { out.println(key + ": " + getPrintValue(event, key)); } } out.println(); out.flush(); } } EventPrinter(PrintStream out, boolean verbose); }
EventPrinter implements Consumer<Event> { @Override public void accept(Event event) { out.println(getTimeStamp(event) + " - " + event.getTopic()); if (verbose) { for (String key : event.getPropertyNames()) { if (!key.equals("event.topics") && !key.equals("timestamp")) { out.println(key + ": " + getPrintValue(event, key)); } } out.println(); out.flush(); } } EventPrinter(PrintStream out, boolean verbose); @Override void accept(Event event); }
EventPrinter implements Consumer<Event> { @Override public void accept(Event event) { out.println(getTimeStamp(event) + " - " + event.getTopic()); if (verbose) { for (String key : event.getPropertyNames()) { if (!key.equals("event.topics") && !key.equals("timestamp")) { out.println(key + ": " + getPrintValue(event, key)); } } out.println(); out.flush(); } } EventPrinter(PrintStream out, boolean verbose); @Override void accept(Event event);  }