MinimumSizeToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { int offset = builder.length(); token.render(logEntry, builder); int size = builder.length() - offset; for (int i = 0; i < minimumSize - size; ++i) { builder.append(' '); } } MinimumSizeToken(final Token token, final int size); @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 renderLongerTextThanMinimumSize() { MinimumSizeToken token = new MinimumSizeToken(new PlainTextToken("Hello!"), 5); assertThat(render(token)).isEqualTo("Hello!"); }
@Test public void renderTextOfEqualLengthToMinimumSize() { MinimumSizeToken token = new MinimumSizeToken(new PlainTextToken("Hello!"), 6); assertThat(render(token)).isEqualTo("Hello!"); }
@Test public void renderShorterTextThanMinimumSize() { MinimumSizeToken token = new MinimumSizeToken(new PlainTextToken("Hello!"), 7); assertThat(render(token)).isEqualTo("Hello! "); token = new MinimumSizeToken(new PlainTextToken("Hello!"), 8); assertThat(render(token)).isEqualTo("Hello! "); }