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.course.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  
17  public class TestCourseDTOEqualXMLBeanDefinition {
18  
19  
20  
21  
22  	private String formatAsString(List<String> errors) {
23  		int i = 0;
24  		StringBuilder builder = new StringBuilder();
25  		for (String error : errors) {
26  			i++;
27  			builder.append(i + ". " + error + "\n");
28  		}
29  		return builder.toString();
30  	}
31  
32  	@Test
33  	public void getLinkedListFields() {
34  		ComplexSubstructuresHelper helpme = new ComplexSubstructuresHelper();
35  		ArrayList<Field> fields = new ArrayList<Field>();
36  		fields = helpme.getAllFields(fields, StatementInfo.class);
37  		for (Field field : fields) {
38  			System.out.println(field.getName());
39  		}
40  	}
41  	
42  	@Test
43  	public void testCourseDTOsAgainstDataDictionary() {
44  		System.out.println("testing course dictionary");
45  		Set<String> startingClasses = new LinkedHashSet();
46          startingClasses.add(ActivityInfo.class.getName());
47          startingClasses.add(CourseCrossListingInfo.class.getName());
48          startingClasses.add(CourseExpenditureInfo.class.getName());
49          startingClasses.add(CourseFeeInfo.class.getName());
50  		startingClasses.add(CourseJointInfo.class.getName());
51  		startingClasses.add(CourseRevenueInfo.class.getName());
52  		startingClasses.add(CourseVariationInfo.class.getName());
53  		startingClasses.add(FormatInfo.class.getName());
54  		startingClasses.add(LoDisplayInfo.class.getName());
55  		
56  		String contextFile = "ks-courseInfo-dictionary-context";
57  		String outFile = "target/" + contextFile + ".txt";
58  		DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
59  				outFile, startingClasses, contextFile + ".xml", true);
60  		helper.setPrintDescrepenciesOnly(true);
61  		List<String> errors = helper.doTest();
62  		if (errors.size() > 0) {
63  			fail("failed dictionary validation:\n" + formatAsString(errors));
64  		}
65  
66  	}
67  	
68  	//@Test
69  	public void testCourseDTOsAgainstDataDictionary_courseInfo() {
70  		System.out.println("testing courseInfo dictionary");
71  		Set<String> startingClasses = new LinkedHashSet();
72  		
73  		startingClasses.add(CourseInfo.class.getName());
74  		
75  		String contextFile = "ks-courseInfo-dictionary-context";
76  		String outFile = "target/" + contextFile + ".txt";
77  		DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
78  				outFile, startingClasses, contextFile + ".xml", true);
79  		helper.setPrintDescrepenciesOnly(true);
80  		List<String> errors = helper.doTest();
81  		if (errors.size() > 0) {
82  			fail("failed dictionary validation:\n" + formatAsString(errors));
83  		}
84  	}
85  }