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