@Test public void applyExceptionOnly() throws SQLException { Exception exception = new UnsupportedOperationException(); PreparedStatement statement = mock(PreparedStatement.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); new MessageAndExceptionToken(Collections.emptyList()).apply(createLogEntry(null, exception), statement, 1); verify(statement).setString(eq(1), captor.capture()); assertThat(captor.getValue()) .startsWith(UnsupportedOperationException.class.getName()) .contains(MessageAndExceptionTokenTest.class.getName(), "applyExceptionOnly") .hasLineCount(exception.getStackTrace().length + 1); }
@Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { if (logEntry.getException() == null) { statement.setString(index, logEntry.getMessage()); } else { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } }
MessageAndExceptionToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { if (logEntry.getException() == null) { statement.setString(index, logEntry.getMessage()); } else { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } } }
MessageAndExceptionToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { if (logEntry.getException() == null) { statement.setString(index, logEntry.getMessage()); } else { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } } MessageAndExceptionToken(final List<ThrowableFilter> filters); }
MessageAndExceptionToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { if (logEntry.getException() == null) { statement.setString(index, logEntry.getMessage()); } else { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } } MessageAndExceptionToken(final List<ThrowableFilter> filters); @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); }
MessageAndExceptionToken implements Token { @Override public void apply(final LogEntry logEntry, final PreparedStatement statement, final int index) throws SQLException { if (logEntry.getException() == null) { statement.setString(index, logEntry.getMessage()); } else { StringBuilder builder = new StringBuilder(); render(logEntry, builder); statement.setString(index, builder.toString()); } } MessageAndExceptionToken(final List<ThrowableFilter> filters); @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);  }