LoggerTagToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { String tag = logEntry.getTag(); if (tag == null) { statement.setString(index, DEFAULT_EMPTY_TAG.equals(empty) ? null : empty); } else { statement.setString(index, tag); } } LoggerTagToken();   LoggerTagToken(final String empty); @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 applyExistingTag() throws SQLException { LoggerTagToken token = new LoggerTagToken(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry("test"), statement, 1); verify(statement).setString(1, "test"); }
@Test public void applyDefaultEmptyTag() throws SQLException { LoggerTagToken token = new LoggerTagToken(); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(null), statement, 1); verify(statement).setString(1, null); }
@Test public void applyDefinedEmptyTag() throws SQLException { LoggerTagToken token = new LoggerTagToken("-"); PreparedStatement statement = mock(PreparedStatement.class); token.apply(createLogEntry(null), statement, 1); verify(statement).setString(1, "-"); }