1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
56 inputFiles.add(calculateXmlFileName(LprInfo.class));
57
58 inputFiles.add(calculateXmlFileName(AppliedHoldInfo.class));
59 inputFiles.add(calculateXmlFileName(HoldIssueInfo.class));
60
61 inputFiles.add(calculateXmlFileName(AtpInfo.class));
62 inputFiles.add(calculateXmlFileName(MilestoneInfo.class));
63 inputFiles.add(calculateXmlFileName(AtpAtpRelationInfo.class));
64
65 inputFiles.add(calculateXmlFileName(LuiInfo.class));
66 inputFiles.add(calculateXmlFileName(LuiLuiRelationInfo.class));
67 inputFiles.add(calculateXmlFileName(LuiCapacityInfo.class));
68
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
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 }