InsertColumnsImpl extends BaseSqlPart implements InsertColumns { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { builder.prepend(')'); for (int i = mColumnNames.length - 1; i >= 0; i--) { builder.prepend(mColumnNames[i]); if (i > 0) { builder.prepend(','); } } builder.prepend('('); } InsertColumnsImpl(@NotNull final String[] columnNames, @NotNull final SqlPart previous); @NotNull @Override Values values(@NotNull final Object... expressions); @Override void prependTo(@NotNull final RawSqlBuilder builder); @Nullable @Override SqlPart previous(); int getColumnCount();  }
@Test public void prependTo_singleColumn_prependsProperSql() { InsertColumnsImpl insertColumns = new InsertColumnsImpl(new String[] {"a"}, mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); insertColumns.prependTo(builder); assertThat(builder.toString(), is("(a)")); }
@Test public void prependTo_multipleColumns_prependsProperSql() { InsertColumnsImpl insertColumns = new InsertColumnsImpl(new String[] {"a", "b", "c"}, mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); insertColumns.prependTo(builder); assertThat(builder.toString(), is("(a,b,c)")); }