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  	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  	// @Test
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(AccreditationInfo.class.getName());
43  		  startingClasses.add(AdminOrgInfo.class.getName());
44  		  startingClasses.add(AffiliatedOrgInfo.class.getName());
45  		  startingClasses.add(CluAccountingInfo.class.getName());
46  		  startingClasses.add(CluCluRelationInfo.class.getName());
47  		  startingClasses.add(CluFeeInfo.class.getName());
48  		  startingClasses.add(CluFeeRecordInfo.class.getName()); 
49  		  startingClasses.add(CluIdentifierInfo.class.getName());
50  		  startingClasses.add(CluInfo.class.getName());
51  		  startingClasses.add(CluInstructorInfo.class.getName());
52  		  startingClasses.add(CluLoRelationInfo.class.getName());
53  		  startingClasses.add(CluPublicationInfo.class.getName());
54  		  startingClasses.add(CluResultInfo.class.getName());
55  		  startingClasses.add(CluSetInfo.class.getName());
56  		  startingClasses.add(CluSetTreeViewInfo.class.getName());
57  		  startingClasses.add(ExpenditureInfo.class.getName());
58  		  startingClasses.add(FeeInfo.class.getName());
59  		  startingClasses.add(FieldInfo.class.getName());
60  		  startingClasses.add(LuCodeInfo.class.getName());
61  		  // startingClasses.add(LuDocRelationInfo.class.getName());
62  		  startingClasses.add(MembershipQueryInfo.class.getName());
63  		  startingClasses.add(ResultOptionInfo.class.getName());
64  		  startingClasses.add(RevenueInfo.class.getName());
65  		  
66  		  String contextFile = "ks-cluInfo-dictionary-context";
67  		  String outFile = "target/" + contextFile + ".txt";
68  		  DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
69  		    outFile, startingClasses, contextFile + ".xml", false);
70  		  helper.setPrintDescrepenciesOnly(true);
71  		  List<String> errors = helper.doTest();
72  		  if (errors.size() > 0) {
73  		   fail("failed dictionary validation:\n" + formatAsString(errors));
74  		  }
75  
76  	}
77  }