ThreadNameToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { Thread thread = logEntry.getThread(); builder.append(thread == null ? null : thread.getName()); } ThreadNameToken(); @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 renderThreadName() { ThreadNameToken token = new ThreadNameToken(); Thread thread = new Thread("MyThread"); assertThat(render(token, thread)).isEqualTo("MyThread"); }
@Test public void renderThreadNameIfThreadIsNull() { ThreadNameToken token = new ThreadNameToken(); assertThat(render(token, null)).isEqualTo("null"); }