public static String formatSql(final AstNode root) {
    final StringBuilder builder = new StringBuilder();
    new Formatter(builder).process(root, 0);
    return StringUtils.stripEnd(builder.toString(), "\n");
  }
@Test
  public void shouldFormatRightJoinWithWithin() {
    final Join join = new Join(leftAlias, ImmutableList.of(new JoinedSource(
        Optional.empty(),
        rightAlias,
        JoinedSource.Type.RIGHT,
        criteria,
        Optional.of(new WithinExpression(10, TimeUnit.SECONDS)))));

    final String expected = "`left` L\nRIGHT OUTER JOIN `right` R WITHIN 10 SECONDS ON "
        + "(('left.col0' = 'right.col0'))";
    assertEquals(expected, SqlFormatter.formatSql(join));
  }