View Javadoc

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.r2.common.datadictionary.util;
17  
18  import org.junit.Test;
19  import org.kuali.rice.krad.datadictionary.DataObjectEntry;
20  import org.kuali.student.enrollment.acal.dto.*;
21  import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
22  import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
23  import org.kuali.student.enrollment.courseoffering.dto.SeatPoolDefinitionInfo;
24  import org.kuali.student.enrollment.lpr.dto.LprInfo;
25  import org.kuali.student.enrollment.lui.dto.LuiCapacityInfo;
26  import org.kuali.student.enrollment.lui.dto.LuiInfo;
27  import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo;
28  import org.kuali.student.r2.core.atp.dto.AtpAtpRelationInfo;
29  import org.kuali.student.r2.core.atp.dto.AtpInfo;
30  import org.kuali.student.r2.core.atp.dto.MilestoneInfo;
31  import org.kuali.student.r2.core.hold.dto.AppliedHoldInfo;
32  import org.kuali.student.r2.core.hold.dto.HoldIssueInfo;
33  import org.springframework.context.ApplicationContext;
34  import org.springframework.context.support.ClassPathXmlApplicationContext;
35  
36  import java.util.ArrayList;
37  import java.util.List;
38  import java.util.Map;
39  
40  public class TestServiceDictionaries {
41  
42      private String calculateXmlFileName(Class<?> clazz) {
43          return "ks-" + clazz.getSimpleName() + "-dictionary.xml";
44      }
45  
46      public List<String> getInputFiles() {
47          List<String> inputFiles = new ArrayList<String>();
48  //       Academic Calendar (ACAL) Service
49          inputFiles.add(calculateXmlFileName(AcademicCalendarInfo.class));
50          inputFiles.add(calculateXmlFileName(HolidayCalendarInfo.class));
51          inputFiles.add(calculateXmlFileName(TermInfo.class));
52          inputFiles.add(calculateXmlFileName(HolidayInfo.class));
53          inputFiles.add(calculateXmlFileName(AcalEventInfo.class));
54          inputFiles.add(calculateXmlFileName(KeyDateInfo.class));
55  //       Lui Person Relation (LPR) Service
56          inputFiles.add(calculateXmlFileName(LprInfo.class));
57  //      Hold Service
58          inputFiles.add(calculateXmlFileName(AppliedHoldInfo.class));
59          inputFiles.add(calculateXmlFileName(HoldIssueInfo.class));
60  //      Academic Time Period (ATP) Service
61          inputFiles.add(calculateXmlFileName(AtpInfo.class));
62          inputFiles.add(calculateXmlFileName(MilestoneInfo.class));
63          inputFiles.add(calculateXmlFileName(AtpAtpRelationInfo.class));
64  //       Learning Unit Instance (LUI) Service
65          inputFiles.add(calculateXmlFileName(LuiInfo.class));
66          inputFiles.add(calculateXmlFileName(LuiLuiRelationInfo.class));
67          inputFiles.add(calculateXmlFileName(LuiCapacityInfo.class));
68  //       Course Offering Service"
69          inputFiles.add(calculateXmlFileName(CourseOfferingInfo.class));
70          inputFiles.add(calculateXmlFileName(ActivityOfferingInfo.class));
71          inputFiles.add(calculateXmlFileName(SeatPoolDefinitionInfo.class));
72          return inputFiles;
73      }
74  
75      @Test
76      public void testDictionaries() {
77          System.out.println("testing dictionary files");
78          List<String> supportFiles = new ArrayList();
79          for (String inputFile : this.getInputFiles()) {
80              this.doTest(inputFile, supportFiles);
81          }
82      }
83  
84      public void doTest(String dictFileName, List<String> supportFiles) {
85          List<String> configLocations = new ArrayList(supportFiles);
86  //        System.out.println ("DictionaryTesterHelper: adding " + supportFiles.size() + " support files");
87          configLocations.add("classpath:" + dictFileName);
88          String[] configLocs = configLocations.toArray(new String[0]);
89          ApplicationContext ac = new ClassPathXmlApplicationContext(configLocs);
90          Map<String, DataObjectEntry> beansOfType =
91                  ac.getBeansOfType(DataObjectEntry.class);
92          for (DataObjectEntry doe : beansOfType.values()) {
93              System.out.println("Loading object structure: " + doe.getFullClassName());
94              if ("org.kuali.rice.krad.bo.AttributeReferenceDummy".equals(doe.getFullClassName())) {
95                  continue;
96              }
97              doe.completeValidation();
98          }
99          return;
100     }
101 }