Clover Coverage Report - Liquibase Integration Tests 2.0.2
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
20   56   4   10
4   46   0.2   2
2     2  
1    
 
  RenameColumnExecuteTest       Line # 16 20 0% 4 26 0% 0.0
 
No Tests
 
1    package liquibase.statementexecute;
2   
3    import liquibase.database.Database;
4    import liquibase.database.core.*;
5    import liquibase.database.typeconversion.TypeConverterFactory;
6    import liquibase.statement.NotNullConstraint;
7    import liquibase.statement.SqlStatement;
8    import liquibase.statement.core.CreateTableStatement;
9    import liquibase.statement.core.RenameColumnStatement;
10    import liquibase.test.DatabaseTestContext;
11    import org.junit.Test;
12   
13    import java.util.ArrayList;
14    import java.util.List;
15   
 
16    public class RenameColumnExecuteTest extends AbstractExecuteTest {
17   
18    protected static final String TABLE_NAME = "table_name";
19    protected static final String COLUMN_NAME = "column_name";
20   
21   
 
22  0 toggle @Override
23    protected List<? extends SqlStatement> setupStatements(Database database) {
24  0 ArrayList<CreateTableStatement> statements = new ArrayList<CreateTableStatement>();
25  0 CreateTableStatement table = new CreateTableStatement(null, TABLE_NAME);
26  0 if (database instanceof MySQLDatabase) {
27  0 table.addPrimaryKeyColumn("id", TypeConverterFactory.getInstance().findTypeConverter(database).getDataType("int", false), null, "pk_", null);
28    } else {
29  0 table.addColumn("id", TypeConverterFactory.getInstance().findTypeConverter(database).getDataType("int", false), null, new NotNullConstraint());
30    }
31  0 table.addColumn(COLUMN_NAME, TypeConverterFactory.getInstance().findTypeConverter(database).getDataType("int", false));
32  0 statements.add(table);
33   
34  0 if (database.supportsSchemas()) {
35  0 table = new CreateTableStatement(DatabaseTestContext.ALT_SCHEMA, TABLE_NAME);
36  0 table
37    .addColumn("id", TypeConverterFactory.getInstance().findTypeConverter(database).getDataType("int", false), null, new NotNullConstraint());
38  0 statements.add(table);
39    }
40  0 return statements;
41    }
42   
 
43  0 toggle @SuppressWarnings("unchecked")
44    @Test
45    public void noSchema() throws Exception {
46  0 this.statementUnderTest = new RenameColumnStatement(null, TABLE_NAME, COLUMN_NAME, "new_name", "int");
47   
48  0 assertCorrect("rename column table_name.column_name to new_name", DerbyDatabase.class, InformixDatabase.class, MaxDBDatabase.class);
49  0 assertCorrect("alter table table_name alter column column_name rename to new_name", H2Database.class, HsqlDatabase.class);
50  0 assertCorrect("alter table table_name alter column column_name to new_name", FirebirdDatabase.class);
51  0 assertCorrect("alter table `table_name` change `column_name` `new_name` int", MySQLDatabase.class);
52  0 assertCorrect("exec sp_rename '[dbo].[table_name].[column_name]', 'new_name'", MSSQLDatabase.class);
53  0 assertCorrect("alter table [table_name] rename \"column_name\" to \"new_name\"",SybaseASADatabase.class);
54  0 assertCorrectOnRest("alter table [table_name] rename column [column_name] to [new_name]");
55    }
56    }