MarkdownTableFormatter implements TableFormatter { @Override public String format(final TableData table) { final StringBuilder builder = new StringBuilder(); try { formatTo(table, builder); } catch (IOException e) { throw new IllegalStateException("We did not expect an IOException.", e); } return builder.toString(); }  @Override String format(final TableData table); @Override void formatTo(final TableData table, final Appendable appendable); static final char PAD_CHAR; static final String NEWLINE; static final String WHITESPACE; }
@Test public void format_should_printHeaders() { final TableData table = Daleq.aTable(TheTable.class).build(context); assertThat( formatter.format(table), is(lines( "| ID | NAME | STUFF |", "|---:|-----:|------:|") ) ); }
@Test public void should_alignToTheLongestValue() { final TableData table = Daleq.aTable(ColumnLength.class) .withRowsBetween(0, 4) .having(ColumnLength.COLUMN, "A", "ABCDEFGHIJ", "ABCDEF", "ABCDEFGHI", "" ) .build(context); assertThat( formatter.format(table), is(lines( "| COLUMN |", "|-----------:|", "| A |", "| ABCDEFGHIJ |", "| ABCDEF |", "| ABCDEFGHI |", "| |" ) ) ); }