AsImpl extends BaseFinishedStatement implements As { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { for (SqlPart sqlPart : mSelectStatement) { sqlPart.prependTo(builder); builder.prepend(' '); } builder.prepend("AS"); } AsImpl(@NotNull final FinishedSelectStatement selectStatement, @NotNull final SqlPart previous); @Override void prependTo(@NotNull final RawSqlBuilder builder); @Nullable @Override SqlPart previous();  }
@Test public void prependTo_prependsProperSql() { AsImpl as = new AsImpl(select().from("my_table"), mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); as.prependTo(builder); assertThat(builder.toString(), is("AS SELECT * FROM my_table")); }