ThreadNameToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { Thread thread = logEntry.getThread(); statement.setString(index, 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 applyThreadName() throws SQLException { ThreadNameToken token = new ThreadNameToken(); Thread thread = new Thread("MyThread"); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(thread), statement, 1); verify(statement).setString(1, "MyThread"); }
@Test public void applyThreadNameIfThreadIsNull() throws SQLException { ThreadNameToken token = new ThreadNameToken(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(null), statement, 1); verify(statement).setString(1, null); }