SetImpl extends BaseFinishedSqlPart implements Set { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { for (int i = mColumnNames.length - 1; i >= 0; i--) { builder.prepend("=?").prepend(mColumnNames[i]); if (i > 0) { builder.prepend(','); } } builder.prepend("SET "); } SetImpl(@NotNull final String[] columnNames, @NotNull final SqlPart previous); @NotNull @Override UpdateValues values(@NotNull final Object... values); @Override void prependTo(@NotNull final RawSqlBuilder builder); @Nullable @Override SqlPart previous(); int getColumnCount();  }
@Test public void prependTo_withSingleColumn_prependsProperSql() { SetImpl set = new SetImpl(new String[] {"a"}, mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); set.prependTo(builder); assertThat(builder.toString(), is("SET a=?")); }
@Test public void prependTo_withMultipleColumns_prependsProperSql() { SetImpl set = new SetImpl(new String[] {"a", "b", "c"}, mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); set.prependTo(builder); assertThat(builder.toString(), is("SET a=?,b=?,c=?")); }