@Override @Test public void generateStatement() throws Exception { SqlStatement[] sqlStatements = refactoring.generateStatements(new MockDatabase()); assertEquals(1, sqlStatements.length); assertTrue(sqlStatements[0] instanceof InsertStatement); assertEquals("123", ((InsertStatement) sqlStatements[0]).getColumnValue("id").toString()); assertEquals("Andrew", ((InsertStatement) sqlStatements[0]).getColumnValue("name").toString()); assertEquals("21", ((InsertStatement) sqlStatements[0]).getColumnValue("age").toString()); assertEquals("1.78", ((InsertStatement) sqlStatements[0]).getColumnValue("height").toString()); }
public SqlStatement[] generateStatements(Database database) { InsertStatement statement = new InsertStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName()); for (ColumnConfig column : columns) { if (database.supportsAutoIncrement() && column.isAutoIncrement() != null && column.isAutoIncrement()) { continue; } statement.addColumnValue(column.getName(), column.getValueObject()); } return new SqlStatement[]{ statement }; }
InsertDataChange extends AbstractChange implements ChangeWithColumns<ColumnConfig> { public SqlStatement[] generateStatements(Database database) { InsertStatement statement = new InsertStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName()); for (ColumnConfig column : columns) { if (database.supportsAutoIncrement() && column.isAutoIncrement() != null && column.isAutoIncrement()) { continue; } statement.addColumnValue(column.getName(), column.getValueObject()); } return new SqlStatement[]{ statement }; } }
InsertDataChange extends AbstractChange implements ChangeWithColumns<ColumnConfig> { public SqlStatement[] generateStatements(Database database) { InsertStatement statement = new InsertStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName()); for (ColumnConfig column : columns) { if (database.supportsAutoIncrement() && column.isAutoIncrement() != null && column.isAutoIncrement()) { continue; } statement.addColumnValue(column.getName(), column.getValueObject()); } return new SqlStatement[]{ statement }; } InsertDataChange(); }
InsertDataChange extends AbstractChange implements ChangeWithColumns<ColumnConfig> { public SqlStatement[] generateStatements(Database database) { InsertStatement statement = new InsertStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName()); for (ColumnConfig column : columns) { if (database.supportsAutoIncrement() && column.isAutoIncrement() != null && column.isAutoIncrement()) { continue; } statement.addColumnValue(column.getName(), column.getValueObject()); } return new SqlStatement[]{ statement }; } InsertDataChange(); String getSchemaName(); void setSchemaName(String schemaName); String getTableName(); void setTableName(String tableName); List<ColumnConfig> getColumns(); void setColumns(List<ColumnConfig> columns); void addColumn(ColumnConfig column); void removeColumn(ColumnConfig column); SqlStatement[] generateStatements(Database database); String getConfirmationMessage(); }
InsertDataChange extends AbstractChange implements ChangeWithColumns<ColumnConfig> { public SqlStatement[] generateStatements(Database database) { InsertStatement statement = new InsertStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName()); for (ColumnConfig column : columns) { if (database.supportsAutoIncrement() && column.isAutoIncrement() != null && column.isAutoIncrement()) { continue; } statement.addColumnValue(column.getName(), column.getValueObject()); } return new SqlStatement[]{ statement }; } InsertDataChange(); String getSchemaName(); void setSchemaName(String schemaName); String getTableName(); void setTableName(String tableName); List<ColumnConfig> getColumns(); void setColumns(List<ColumnConfig> columns); void addColumn(ColumnConfig column); void removeColumn(ColumnConfig column); SqlStatement[] generateStatements(Database database); String getConfirmationMessage();  }