ThreadIdToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { Thread thread = logEntry.getThread(); builder.append(thread == null ? "?" : thread.getId()); } ThreadIdToken(); @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 renderThreadId() { ThreadIdToken token = new ThreadIdToken(); Thread thread = new Thread(); assertThat(render(token, thread)).isEqualTo(String.valueOf(thread.getId())); }
@Test public void renderThreadIdIfThreadIsNull() { ThreadIdToken token = new ThreadIdToken(); assertThat(render(token, null)).isEqualTo("?"); }