LineNumberToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { int line = logEntry.getLineNumber(); if (line >= 0) { builder.append(line); } else { builder.append("?"); } } LineNumberToken(); @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 renderValidLineNumber() { LineNumberToken token = new LineNumberToken(); assertThat(render(token, 42)).isEqualTo("42"); }
@Test public void renderInvalidLineNumber() { LineNumberToken token = new LineNumberToken(); assertThat(render(token, -1)).isEqualTo("?"); }