Coverage Report - org.kuali.student.datadictionary.util.DictionaryTesterHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
DictionaryTesterHelper
0%
0/23
0%
0/6
3.5
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.student.datadictionary.util;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.HashMap;
 20  
 import java.util.HashSet;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 import org.kuali.rice.kns.datadictionary.DataObjectEntry;
 24  
 import org.springframework.context.ApplicationContext;
 25  
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 26  
 
 27  
 public class DictionaryTesterHelper {
 28  
 
 29  
     private String outputFileName;
 30  
     private String className;
 31  
     private String dictFileName;
 32  
     private String projectUrl;
 33  
 
 34  
     public DictionaryTesterHelper(String outputFileName,
 35  
             String className,
 36  
             String projectUrl,
 37  0
             String dictFileName) {
 38  0
         this.outputFileName = outputFileName;
 39  0
         this.className = className;
 40  0
         this.projectUrl = projectUrl;
 41  0
         this.dictFileName = dictFileName;
 42  0
     }
 43  
     private transient Map<String, DataObjectEntry> objectStructures;
 44  
 
 45  
     public List<String> doTest() {
 46  0
         ApplicationContext ac = new ClassPathXmlApplicationContext(
 47  
                 "classpath:" + dictFileName);
 48  0
         objectStructures = new HashMap();
 49  0
         Map<String, DataObjectEntry> beansOfType =
 50  
                 (Map<String, DataObjectEntry>) ac.getBeansOfType(DataObjectEntry.class);
 51  0
         for (DataObjectEntry objStr : beansOfType.values()) {
 52  0
             objectStructures.put(objStr.getFullClassName(), objStr);
 53  0
             System.out.println("Loading object structure: " + objStr.getFullClassName());
 54  
         }
 55  0
         DataObjectEntry ode = null;
 56  0
         ode = objectStructures.get(className);
 57  0
         if (ode == null) {
 58  0
             throw new RuntimeException("className is not defined in dictionary: " + className);
 59  
         }
 60  0
         DictionaryValidator validator = new DictionaryValidator(ode, new HashSet());
 61  0
         List<String> errors = validator.validate();
 62  0
         if (errors.size() > 0) {
 63  0
             return errors;
 64  
         }
 65  0
         DictionaryFormatter formatter = new DictionaryFormatter(ode, projectUrl, dictFileName, outputFileName);
 66  0
         formatter.formatForHtml();
 67  0
         return new ArrayList<String>();
 68  
     }
 69  
 }