@Test public void wrapStringContentWithTwoColumns() { Result result = mockResult( asList( "c1", "c2" ), "a", "b", "aa", "bb", "aaa", "b", "a", "bbb", "aaaa", "bb", "aa", "bbbb", "aaaaa", "bbbbb" ); ToStringLinePrinter printer = new ToStringLinePrinter(); new TableOutputFormatter(true, 2).formatAndCount(new ListBoltResult(result.list(), result.consume()), printer); String table = printer.result(); assertThat(table, is(String.join(NEWLINE, "+-------------+", "| c1 | c2 |", "+-------------+", "| \"a\" | \"b\" |", "| \"aa\" | \"bb\" |", "| \"aaa | \"b\" |", "\\ \" | |", "| \"a\" | \"bbb |", "| \\ \" |", "| \"aaa | \"bb\" |", "\\ a\" | |", "| \"aa\" | \"bbb |", "| \\ b\" |", "| \"aaa | \"bbb |", "\\ aa\" \\ bb\" |", "+-------------+", NEWLINE))); }
@Override public int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output) { String[] columns = result.getKeys().toArray(new String[0]); if (columns.length == 0) { return 0; } Iterator<Record> records = result.iterate(); return formatResultAndCountRows(columns, records, output); }
TableOutputFormatter implements OutputFormatter { @Override public int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output) { String[] columns = result.getKeys().toArray(new String[0]); if (columns.length == 0) { return 0; } Iterator<Record> records = result.iterate(); return formatResultAndCountRows(columns, records, output); } }
TableOutputFormatter implements OutputFormatter { @Override public int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output) { String[] columns = result.getKeys().toArray(new String[0]); if (columns.length == 0) { return 0; } Iterator<Record> records = result.iterate(); return formatResultAndCountRows(columns, records, output); } TableOutputFormatter(boolean wrap, int numSampleRows); }
TableOutputFormatter implements OutputFormatter { @Override public int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output) { String[] columns = result.getKeys().toArray(new String[0]); if (columns.length == 0) { return 0; } Iterator<Record> records = result.iterate(); return formatResultAndCountRows(columns, records, output); } TableOutputFormatter(boolean wrap, int numSampleRows); @Override int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output); @Override @Nonnull String formatFooter(@Nonnull BoltResult result, int numberOfRows); @Override @Nonnull String formatInfo(@Nonnull ResultSummary summary); @Override @Nonnull String formatPlan(@Nullable ResultSummary summary); @Override Set<Capabilities> capabilities(); }
TableOutputFormatter implements OutputFormatter { @Override public int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output) { String[] columns = result.getKeys().toArray(new String[0]); if (columns.length == 0) { return 0; } Iterator<Record> records = result.iterate(); return formatResultAndCountRows(columns, records, output); } TableOutputFormatter(boolean wrap, int numSampleRows); @Override int formatAndCount(@Nonnull BoltResult result, @Nonnull LinePrinter output); @Override @Nonnull String formatFooter(@Nonnull BoltResult result, int numberOfRows); @Override @Nonnull String formatInfo(@Nonnull ResultSummary summary); @Override @Nonnull String formatPlan(@Nullable ResultSummary summary); @Override Set<Capabilities> capabilities();  }