View Javadoc

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  
19  
20  
21  	private String formatAsString(List<String> errors) {
22  		int i = 0;
23  		StringBuilder builder = new StringBuilder();
24  		for (String error : errors) {
25  			i++;
26  			builder.append(i + ". " + error + "\n");
27  		}
28  		return builder.toString();
29  	}
30  
31  	// @Test
32  	public void getLinkedListFields() {
33  		ComplexSubstructuresHelper helpme = new ComplexSubstructuresHelper();
34  		ArrayList<Field> fields = new ArrayList<Field>();
35  		fields = helpme.getAllFields(fields, StatementInfo.class);
36  		for (Field field : fields) {
37  			System.out.println(field.getName());
38  		}
39  	}
40  
41  	@Test
42  	public void testCluDTOsAgainstDataDictionary() {
43  		  System.out.println("testing statement dictionary");
44  		  Set<String> startingClasses = new LinkedHashSet();
45  		  startingClasses.add(AcademicSubjectOrgInfo.class.getName());
46  		  startingClasses.add(AccreditationInfo.class.getName());
47  		  startingClasses.add(AdminOrgInfo.class.getName());
48  		  startingClasses.add(AffiliatedOrgInfo.class.getName());
49  		  startingClasses.add(CluAccountingInfo.class.getName());
50  		  startingClasses.add(CluCluRelationInfo.class.getName());
51  		  startingClasses.add(CluCreditInfo.class.getName());
52  		  startingClasses.add(CluFeeInfo.class.getName());
53  		  startingClasses.add(CluFeeRecordInfo.class.getName()); 
54  		  startingClasses.add(CluIdentifierInfo.class.getName());
55  		  startingClasses.add(CluInfo.class.getName());
56  		  startingClasses.add(CluInstructorInfo.class.getName());
57  		  startingClasses.add(CluLoRelationInfo.class.getName());
58  		  startingClasses.add(CluPublicationInfo.class.getName());
59  		  startingClasses.add(CluResultInfo.class.getName());
60  		  startingClasses.add(CluSetInfo.class.getName());
61  		  startingClasses.add(CluSetTreeViewInfo.class.getName());
62  		  startingClasses.add(ExpenditureInfo.class.getName());
63  		  startingClasses.add(FeeInfo.class.getName());
64  		  startingClasses.add(FieldInfo.class.getName());
65  		  startingClasses.add(LuCodeInfo.class.getName());
66  		  startingClasses.add(LuDocRelationInfo.class.getName());
67  		  startingClasses.add(MembershipQueryInfo.class.getName());
68  		  startingClasses.add(ResultOptionInfo.class.getName());
69  		  startingClasses.add(RevenueInfo.class.getName());
70  		  
71  		  String contextFile = "ks-cluInfo-dictionary-context";
72  		  String outFile = "target/" + contextFile + ".txt";
73  		  DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
74  		    outFile, startingClasses, contextFile + ".xml", false);
75  		  helper.setPrintDescrepenciesOnly(true);
76  		  List<String> errors = helper.doTest();
77  		  if (errors.size() > 0) {
78  		   fail("failed dictionary validation:\n" + formatAsString(errors));
79  		  }
80  
81  	}
82  }