CreateTableIfNotExistsImpl extends BaseSqlPart implements CreateTableIfNotExists { @Override public void prependTo(@NotNull final RawSqlBuilder builder) { builder.prepend(mTableName); if (mDatabaseName != null) { builder.prepend('.').prepend(mDatabaseName); } builder.prepend("TABLE IF NOT EXISTS "); } CreateTableIfNotExistsImpl(@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);  }
@Test public void prependTo_withOnlyTableName_prependsProperSql() { CreateTableIfNotExistsImpl createTableIfNotExists = new CreateTableIfNotExistsImpl(null, "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); createTableIfNotExists.prependTo(builder); assertThat(builder.toString(), is("TABLE IF NOT EXISTS table")); }
@Test public void prependTo_withDatabaseAndTableName_prependsProperSql() { CreateTableIfNotExistsImpl createTableIfNotExists = new CreateTableIfNotExistsImpl("database", "table", mock(SqlPart.class)); RawSqlBuilder builder = new RawSqlBuilderImpl(); createTableIfNotExists.prependTo(builder); assertThat(builder.toString(), is("TABLE IF NOT EXISTS database.table")); }