PlainTextToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { statement.setString(index, text); } PlainTextToken(final String text); @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 applySimpleText() throws SQLException { PlainTextToken token = new PlainTextToken("Hello World!"); PreparedStatement statement = mock(PreparedStatement.class); token.apply(LogEntryBuilder.empty().create(), statement, 1); verify(statement).setString(1, "Hello World!"); }
@Test public void applyWindowsNewLines() throws SQLException { LogEntry logEntry = LogEntryBuilder.empty().create(); PreparedStatement statement = mock(PreparedStatement.class); new PlainTextToken("\r\n").apply(logEntry, statement, 1); verify(statement).setString(1, NEW_LINE); }
@Test public void applyUnixNewLines() throws SQLException { LogEntry logEntry = LogEntryBuilder.empty().create(); PreparedStatement statement = mock(PreparedStatement.class); new PlainTextToken("\n").apply(logEntry, statement, 1); verify(statement).setString(1, NEW_LINE); }
@Test public void applyMacNewLines() throws SQLException { LogEntry logEntry = LogEntryBuilder.empty().create(); PreparedStatement statement = mock(PreparedStatement.class); new PlainTextToken("\r").apply(logEntry, statement, 1); verify(statement).setString(1, NEW_LINE); }