AlterTableImpl extends BaseSqlPart implements AlterTable { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { builder.prepend(mTableName); if (mDatabaseName != null) { builder.prepend('.').prepend(mDatabaseName); } builder.prepend("TABLE "); } AlterTableImpl(@Nullable final String databaseName, @NotNull final String tableName, @NotNull final SqlPart previous); @NotNull @Override RenameTo renameTo(@NotNull final String newTableName); @NotNull @Override AddColumn add(@NotNull final Column column); @NotNull @Override AddColumn addColumn(@NotNull final Column column); @Override void prependTo(@NotNull final RawSqlBuilder builder); @Nullable @Override SqlPart previous();  }
@Test public void prependOnlyTable_prependsProperSql() { AlterTableImpl table = new AlterTableImpl(null, "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); table.prependTo(builder); assertThat(builder.toString(), is("TABLE table")); }
@Test public void prependDatabaseAndTable_prependsProperSql() { AlterTableImpl table = new AlterTableImpl("database", "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); table.prependTo(builder); assertThat(builder.toString(), is("TABLE database.table")); }