Coverage Report - liquibase.precondition.core.AndPrecondition
 
Classes in this File Line Coverage Branch Coverage Complexity
AndPrecondition
81%
13/16
100%
4/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  
 import java.util.ArrayList;
 14  
 import java.util.List;
 15  
 
 16  
 /**
 17  
  * Container class for all preconditions on a change log.
 18  
  */
 19  58
 public class AndPrecondition extends PreconditionLogic {
 20  
 
 21  
     public Warnings warn(Database database) {
 22  0
         return new Warnings();
 23  
     }
 24  
 
 25  
     public ValidationErrors validate(Database database) {
 26  0
         return new ValidationErrors();
 27  
     }
 28  
 
 29  
     public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet)
 30  
             throws PreconditionFailedException, PreconditionErrorException {
 31  3
         boolean allPassed = true;
 32  3
         List<FailedPrecondition> failures = new ArrayList<FailedPrecondition>();
 33  3
         for (Precondition precondition : getNestedPreconditions()) {
 34  
             try {
 35  1
                 precondition.check(database, changeLog, changeSet);
 36  1
             } catch (PreconditionFailedException e) {
 37  1
                 failures.addAll(e.getFailedPreconditions());
 38  1
                 allPassed = false;
 39  1
                 break;
 40  0
             }
 41  
         }
 42  3
         if (!allPassed) {
 43  1
             throw new PreconditionFailedException(failures);
 44  
         }
 45  2
     }
 46  
 
 47  
     public String getName() {
 48  17
         return "and";
 49  
     }
 50  
 }