1 package liquibase.change.core; 2 3 import liquibase.change.AbstractChangeTest; 4 import liquibase.database.Database; 5 import liquibase.database.core.MockDatabase; 6 import liquibase.database.core.SQLiteDatabase; 7 import liquibase.statement.SqlStatement; 8 import liquibase.statement.core.DropDefaultValueStatement; 9 import static org.junit.Assert.*; 10 import org.junit.Test; 11 12 public class DropDefaultValueChangeTest extends AbstractChangeTest { 13 14 @Override 15 @Test 16 public void getRefactoringName() throws Exception { 17 assertEquals("Drop Default Value", new DropDefaultValueChange().getChangeMetaData().getDescription()); 18 } 19 20 @Override 21 @Test 22 public void generateStatement() throws Exception { 23 DropDefaultValueChange change = new DropDefaultValueChange(); 24 change.setSchemaName("SCHEMA_NAME"); 25 change.setTableName("TABLE_NAME"); 26 change.setColumnName("COL_HERE"); 27 28 SqlStatement[] sqlStatements = change.generateStatements(new MockDatabase()); 29 assertEquals(1, sqlStatements.length); 30 assertTrue(sqlStatements[0] instanceof DropDefaultValueStatement); 31 assertEquals("SCHEMA_NAME", ((DropDefaultValueStatement) sqlStatements[0]).getSchemaName()); 32 assertEquals("TABLE_NAME", ((DropDefaultValueStatement) sqlStatements[0]).getTableName()); 33 assertEquals("COL_HERE", ((DropDefaultValueStatement) sqlStatements[0]).getColumnName()); 34 } 35 36 @Override 37 @Test 38 public void getConfirmationMessage() throws Exception { 39 DropDefaultValueChange change = new DropDefaultValueChange(); 40 change.setTableName("TABLE_NAME"); 41 change.setColumnName("COL_HERE"); 42 43 assertEquals("Default value dropped from TABLE_NAME.COL_HERE", change.getConfirmationMessage()); 44 } 45 46 @Override 47 protected boolean changeIsUnsupported(Database database) { 48 return database instanceof SQLiteDatabase; 49 } 50 51 }