Coverage Report - org.kuali.rice.test.data.UnitTestDataUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
UnitTestDataUtils
0%
0/24
0%
0/17
4.667
UnitTestDataUtils$1
0%
0/1
N/A
4.667
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.test.data;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.test.SQLDataLoader;
 20  
 
 21  
 /**
 22  
  * Utilities for unit test data annotations. 
 23  
  * 
 24  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 25  
  *
 26  
  */
 27  
 public final class UnitTestDataUtils {
 28  
 
 29  0
         private UnitTestDataUtils() {
 30  0
                 throw new UnsupportedOperationException("do not call");
 31  
         }
 32  
         
 33  
     public static void executeDataLoader(UnitTestData[] data) throws Exception {
 34  0
         for (UnitTestData d: data) {
 35  0
             executeDataLoader(d);
 36  
         }
 37  0
     }
 38  
 
 39  
     public static void executeDataLoader(UnitTestData data) throws Exception {
 40  
         SQLDataLoader sqlDataLoader;
 41  0
         for (UnitTestData.Type type : data.order()) {
 42  0
             switch (type) {
 43  
                 case SQL_FILES : 
 44  0
                     for (UnitTestFile file : data.sqlFiles()) {
 45  0
                         sqlDataLoader = new SQLDataLoader(file.filename(), file.delimiter());
 46  0
                         sqlDataLoader.runSql();
 47  
                     }
 48  0
                     break;
 49  
                 case SQL_STATEMENTS : 
 50  0
                     for (UnitTestSql statement : data.sqlStatements()) {
 51  0
                         sqlDataLoader = new SQLDataLoader(statement.value());
 52  0
                         sqlDataLoader.runSql();
 53  
                     }
 54  0
                     break;
 55  
                 default: break;
 56  
             }
 57  
         }
 58  
         
 59  0
         if (!StringUtils.isEmpty(data.filename())) {
 60  0
             if (!StringUtils.isEmpty(data.value()))
 61  0
                 throw new RuntimeException("UnitTestDataArtifact may not specify both SQL file and content");
 62  0
             sqlDataLoader = new SQLDataLoader(data.filename(), data.delimiter());
 63  0
             sqlDataLoader.runSql();
 64  0
         } else if (!StringUtils.isEmpty(data.value())) {
 65  0
             sqlDataLoader = new SQLDataLoader(data.value());
 66  0
             sqlDataLoader.runSql();
 67  
         }
 68  0
     }
 69  
 }