Coverage Report - liquibase.change.core.RenameViewChange
 
Classes in this File Line Coverage Branch Coverage Complexity
RenameViewChange
76%
13/17
100%
2/2
1.1
 
 1  
 package liquibase.change.core;
 2  
 
 3  
 import liquibase.change.AbstractChange;
 4  
 import liquibase.change.Change;
 5  
 import liquibase.change.ChangeMetaData;
 6  
 import liquibase.database.Database;
 7  
 import liquibase.statement.SqlStatement;
 8  
 import liquibase.statement.core.RenameViewStatement;
 9  
 import liquibase.util.StringUtils;
 10  
 
 11  
 /**
 12  
  * Renames an existing view.
 13  
  */
 14  
 public class RenameViewChange extends AbstractChange {
 15  
     private String schemaName;
 16  
     private String oldViewName;
 17  
     private String newViewName;
 18  
 
 19  
     public RenameViewChange() {
 20  21
         super("renameView", "Rename View", ChangeMetaData.PRIORITY_DEFAULT);
 21  21
     }
 22  
 
 23  
     public String getSchemaName() {
 24  39
         return schemaName;
 25  
     }
 26  
 
 27  
     public void setSchemaName(String schemaName) {
 28  2
         this.schemaName = StringUtils.trimToNull(schemaName);
 29  2
     }
 30  
 
 31  
     public String getOldViewName() {
 32  38
         return oldViewName;
 33  
     }
 34  
 
 35  
     public void setOldViewName(String oldViewName) {
 36  3
         this.oldViewName = oldViewName;
 37  3
     }
 38  
 
 39  
     public String getNewViewName() {
 40  38
         return newViewName;
 41  
     }
 42  
 
 43  
     public void setNewViewName(String newViewName) {
 44  3
         this.newViewName = newViewName;
 45  3
     }
 46  
 
 47  
     public SqlStatement[] generateStatements(Database database) {
 48  38
         return new SqlStatement[] { new RenameViewStatement(getSchemaName() == null ? database.getDefaultSchemaName()
 49  
                 : getSchemaName(), getOldViewName(), getNewViewName()) };
 50  
     }
 51  
 
 52  
     @Override
 53  
     protected Change[] createInverses() {
 54  0
         RenameViewChange inverse = new RenameViewChange();
 55  0
         inverse.setOldViewName(getNewViewName());
 56  0
         inverse.setNewViewName(getOldViewName());
 57  
 
 58  0
         return new Change[] { inverse };
 59  
     }
 60  
 
 61  
     public String getConfirmationMessage() {
 62  1
         return "View " + oldViewName + " renamed to " + newViewName;
 63  
     }
 64  
 
 65  
 }