CreateTableImpl extends BaseFinishedStatement implements CreateTable { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { builder.prepend(mTableName); if (mDatabaseName != null) { builder.prepend('.').prepend(mDatabaseName); } builder.prepend("TABLE "); } CreateTableImpl(@Nullable final String databaseName, @NotNull final String tableName, @NotNull final SqlPart previous); @Override void prependTo(@NotNull final RawSqlBuilder builder); @Nullable @Override SqlPart previous(); @NotNull @Override CreateColumns columns(@NotNull final Column... columns); @NotNull @Override As as(@NotNull final FinishedSelectStatement select);  }
@Test public void prependTo_withOnlyTableName_prependsProperSql() { CreateTableImpl createTable = new CreateTableImpl(null, "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); createTable.prependTo(builder); assertThat(builder.toString(), is("TABLE table")); }
@Test public void prependTo_withDatabaseAndTableName_prependsProperSql() { CreateTableImpl createTable = new CreateTableImpl("database", "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); createTable.prependTo(builder); assertThat(builder.toString(), is("TABLE database.table")); }