1 package liquibase.change.core; 2 3 import liquibase.change.AbstractChangeTest; 4 import static org.junit.Assert.*; 5 import org.junit.Test; 6 7 /** 8 * Tests for {@link CreateIndexChange} 9 */ 10 public class CreateIndexChangeTest extends AbstractChangeTest { 11 12 @Override 13 @Test 14 public void getRefactoringName() throws Exception { 15 assertEquals("Create Index", new CreateIndexChange().getChangeMetaData().getDescription()); 16 } 17 18 @Override 19 @Test 20 public void generateStatement() throws Exception { 21 // new DatabaseTestTemplate().testOnAllDatabases(new DatabaseTest() { 22 // public void performTest(Database database) throws Exception { 23 // CreateIndexChange change = new CreateIndexChange(); 24 // change.setIndexName("IDX_NAME"); 25 // change.setSchemaName("SCHEMA_NAME"); 26 // change.setTableName("TABLE_NAME"); 27 // change.setTablespace("TABLESPACE_NAME"); 28 // 29 // ColumnConfig column = new ColumnConfig(); 30 // column.setName("COL_NAME"); 31 // change.addColumn(column); 32 // 33 // ColumnConfig column2 = new ColumnConfig(); 34 // column2.setName("COL2_NAME"); 35 // change.addColumn(column2); 36 // 37 // SqlStatement[] sqlStatements = change.generateStatements(database); 38 // assertEquals(1, sqlStatements.length); 39 // assertTrue(sqlStatements[0] instanceof CreateIndexStatement); 40 // 41 // assertEquals("IDX_NAME", ((CreateIndexStatement) sqlStatements[0]).getIndexName()); 42 // assertEquals("SCHEMA_NAME", ((CreateIndexStatement) sqlStatements[0]).getTableSchemaName()); 43 // assertEquals("TABLE_NAME", ((CreateIndexStatement) sqlStatements[0]).getTableName()); 44 // assertEquals("TABLESPACE_NAME", ((CreateIndexStatement) sqlStatements[0]).getTablespace()); 45 // assertEquals(2, ((CreateIndexStatement) sqlStatements[0]).getColumns().length); 46 // assertEquals("COL_NAME", ((CreateIndexStatement) sqlStatements[0]).getColumns()[0]); 47 // assertEquals("COL2_NAME", ((CreateIndexStatement) sqlStatements[0]).getColumns()[1]); 48 // } 49 // }); 50 } 51 52 @Override 53 @Test 54 public void getConfirmationMessage() throws Exception { 55 CreateIndexChange refactoring = new CreateIndexChange(); 56 refactoring.setIndexName("IDX_TEST"); 57 58 assertEquals("Index IDX_TEST created", refactoring.getConfirmationMessage()); 59 } 60 }