IndentationToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } IndentationToken(final Token token, final int indentation); @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 applySingleLine() throws SQLException { IndentationToken token = new IndentationToken(new PlainTextToken("Hello World!"), 2); PreparedStatement statement = mock(PreparedStatement.class); token.apply(LogEntryBuilder.empty().create(), statement, 1); verify(statement).setString(1, "Hello World!"); }
@Test public void applyTwoLines() throws SQLException { IndentationToken token = new IndentationToken(new PlainTextToken("Hello" + NEW_LINE + "World!"), 2); PreparedStatement statement = mock(PreparedStatement.class); token.apply(LogEntryBuilder.empty().create(), statement, 1); verify(statement).setString(1, "Hello" + NEW_LINE + " World!"); }
@Test public void applyMultipleLines() throws SQLException { IndentationToken token = new IndentationToken(new PlainTextToken("A" + NEW_LINE + "B" + NEW_LINE + "C"), 2); PreparedStatement statement = mock(PreparedStatement.class); token.apply(LogEntryBuilder.empty().create(), statement, 1); verify(statement).setString(1, "A" + NEW_LINE + " B" + NEW_LINE + " C"); }
@Test public void applyTabulators() throws SQLException { IndentationToken token = new IndentationToken(new PlainTextToken("Hello" + NEW_LINE + "\tWorld\t!"), 2); PreparedStatement statement = mock(PreparedStatement.class); token.apply(LogEntryBuilder.empty().create(), statement, 1); verify(statement).setString(1, "Hello" + NEW_LINE + " World\t!"); }