ThreadIdToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { Thread thread = logEntry.getThread(); if (thread == null) { statement.setNull(index, Types.BIGINT); } else { statement.setLong(index, 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 applyThreadId() throws SQLException { ThreadIdToken token = new ThreadIdToken(); Thread thread = new Thread(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(thread), statement, 1); verify(statement).setLong(1, thread.getId()); }
@Test public void applyThreadIdIfThreadIsNull() throws SQLException { ThreadIdToken token = new ThreadIdToken(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(null), statement, 1); verify(statement).setNull(1, Types.BIGINT); }