TimestampToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { statement.setLong(index, getTime(logEntry)); } TimestampToken();   TimestampToken(final String unit); @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 applySecondsTimestamp() throws SQLException { TimestampToken token = new TimestampToken("seconds"); LocalDateTime now = LocalDateTime.now(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(now), statement, 1); verify(statement).setLong(1, now.atZone(ZoneOffset.UTC).toEpochSecond()); }