Coverage Report - liquibase.precondition.core.NotPrecondition
 
Classes in this File Line Coverage Branch Coverage Complexity
NotPrecondition
14%
2/14
0%
0/4
2
 
 1  
 package liquibase.precondition.core;
 2  
 
 3  
 import liquibase.changelog.DatabaseChangeLog;
 4  
 import liquibase.changelog.ChangeSet;
 5  
 import liquibase.database.Database;
 6  
 import liquibase.exception.PreconditionErrorException;
 7  
 import liquibase.exception.PreconditionFailedException;
 8  
 import liquibase.exception.ValidationErrors;
 9  
 import liquibase.exception.Warnings;
 10  
 import liquibase.precondition.Precondition;
 11  
 import liquibase.precondition.PreconditionLogic;
 12  
 
 13  
 /**
 14  
  * Class for controling "not" logic in preconditions.
 15  
  */
 16  8
 public class NotPrecondition extends PreconditionLogic {
 17  
 
 18  
     public Warnings warn(Database database) {
 19  0
         return new Warnings();
 20  
     }
 21  
 
 22  
     public ValidationErrors validate(Database database) {
 23  0
         return new ValidationErrors();
 24  
     }
 25  
 
 26  
     public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet)
 27  
             throws PreconditionFailedException, PreconditionErrorException {
 28  0
         for (Precondition precondition : getNestedPreconditions()) {
 29  0
             boolean threwException = false;
 30  
             try {
 31  0
                 precondition.check(database, changeLog, changeSet);
 32  0
             } catch (PreconditionFailedException e) {
 33  
                 ; // that's what we want with a Not precondition
 34  0
                 threwException = true;
 35  0
             }
 36  
 
 37  0
             if (!threwException) {
 38  0
                 throw new PreconditionFailedException("Not precondition failed", changeLog, this);
 39  
             }
 40  0
         }
 41  0
     }
 42  
 
 43  
     public String getName() {
 44  8
         return "not";
 45  
     }
 46  
 }