MessageToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { String message = logEntry.getMessage(); if (message != null) { builder.append(NEW_LINE_PATTERN.matcher(message).replaceAll(NEW_LINE)); } } MessageToken(); @Override Collection<LogEntryValue> getRequiredLogEntryValues(); @Override void render(final LogEntry logEntry, final StringBuilder builder); @Override void apply(final LogEntry logEntry, final PreparedStatement statement, final int index);  }
@Test public void renderMissingMessage() { MessageToken token = new MessageToken(); assertThat(render(token, null)).isEmpty(); }
@Test public void renderTextMessage() { MessageToken token = new MessageToken(); assertThat(render(token, "Hello World!")).isEqualTo("Hello World!"); }
@Test public void convertUnixLineSeparator() { MessageToken token = new MessageToken(); assertThat(render(token, "Hello\nWorld!")).isEqualTo("Hello" + System.lineSeparator() + "World!"); }
@Test public void convertMacintoshLineSeparator() { MessageToken token = new MessageToken(); assertThat(render(token, "Hello\rWorld!")).isEqualTo("Hello" + System.lineSeparator() + "World!"); }
@Test public void convertWindowsLineSeparator() { MessageToken token = new MessageToken(); assertThat(render(token, "Hello\r\nWorld!")).isEqualTo("Hello" + System.lineSeparator() + "World!"); }