1 package org.kuali.student.lum.dto.test;
2
3 import org.junit.Test;
4 import org.kuali.student.r1.common.dictionary.service.impl.ComplexSubstructuresHelper;
5 import org.kuali.student.r2.core.statement.dto.StatementInfo;
6 import org.kuali.student.r2.lum.clu.dto.*;
7
8 import java.lang.reflect.Field;
9 import java.util.ArrayList;
10 import java.util.LinkedHashSet;
11 import java.util.List;
12 import java.util.Set;
13
14 import static org.junit.Assert.fail;
15
16 public class TestCluDTOEqualXMLBeanDefinition {
17
18 private String formatAsString(List<String> errors) {
19 int i = 0;
20 StringBuilder builder = new StringBuilder();
21 for (String error : errors) {
22 i++;
23 builder.append(i + ". " + error + "\n");
24 }
25 return builder.toString();
26 }
27
28
29 public void getLinkedListFields() {
30 ComplexSubstructuresHelper helpme = new ComplexSubstructuresHelper();
31 ArrayList<Field> fields = new ArrayList<Field>();
32 fields = helpme.getAllFields(fields, StatementInfo.class);
33 for (Field field : fields) {
34 System.out.println(field.getName());
35 }
36 }
37
38 @Test
39 public void testCluDTOsAgainstDataDictionary() {
40 System.out.println("testing statement dictionary");
41 Set<String> startingClasses = new LinkedHashSet();
42 startingClasses.add(AcademicSubjectOrgInfo.class.getName());
43 startingClasses.add(AccreditationInfo.class.getName());
44 startingClasses.add(AdminOrgInfo.class.getName());
45 startingClasses.add(AffiliatedOrgInfo.class.getName());
46 startingClasses.add(CluAccountingInfo.class.getName());
47 startingClasses.add(CluCluRelationInfo.class.getName());
48 startingClasses.add(CluCreditInfo.class.getName());
49 startingClasses.add(CluFeeInfo.class.getName());
50 startingClasses.add(CluFeeRecordInfo.class.getName());
51 startingClasses.add(CluIdentifierInfo.class.getName());
52 startingClasses.add(CluInfo.class.getName());
53 startingClasses.add(CluInstructorInfo.class.getName());
54 startingClasses.add(CluLoRelationInfo.class.getName());
55 startingClasses.add(CluPublicationInfo.class.getName());
56 startingClasses.add(CluResultInfo.class.getName());
57 startingClasses.add(CluSetInfo.class.getName());
58 startingClasses.add(CluSetTreeViewInfo.class.getName());
59 startingClasses.add(ExpenditureInfo.class.getName());
60 startingClasses.add(FeeInfo.class.getName());
61 startingClasses.add(FieldInfo.class.getName());
62 startingClasses.add(LuCodeInfo.class.getName());
63 startingClasses.add(LuDocRelationInfo.class.getName());
64 startingClasses.add(MembershipQueryInfo.class.getName());
65 startingClasses.add(ResultOptionInfo.class.getName());
66 startingClasses.add(RevenueInfo.class.getName());
67
68 String contextFile = "ks-cluInfo-dictionary-context";
69 String outFile = "target/" + contextFile + ".txt";
70 DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
71 outFile, startingClasses, contextFile + ".xml", false);
72 helper.setPrintDescrepenciesOnly(true);
73 List<String> errors = helper.doTest();
74 if (errors.size() > 0) {
75 fail("failed dictionary validation:\n" + formatAsString(errors));
76 }
77
78 }
79 }