1 package org.kuali.student.lum.dto.test;
2
3 import static org.junit.Assert.fail;
4
5 import java.lang.reflect.Field;
6 import java.util.ArrayList;
7 import java.util.LinkedHashSet;
8 import java.util.List;
9 import java.util.Set;
10
11 import org.junit.Test;
12 import org.kuali.student.r1.common.dictionary.service.impl.ComplexSubstructuresHelper;
13 import org.kuali.student.r2.core.statement.dto.StatementInfo;
14 import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
15 import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
16 import org.kuali.student.r2.lum.lrc.dto.ResultValueRangeInfo;
17 import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
18
19 public class TestLrcDTOEqualXMLBeanDefinition {
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
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 testProgramDTOsAgainstDataDictionary() {
43 System.out.println("testing statement dictionary");
44
45 Set<String> startingClasses = new LinkedHashSet();
46 startingClasses.add(ResultValueRangeInfo.class.getName());
47 startingClasses.add(ResultValuesGroupInfo.class.getName());
48 startingClasses.add(ResultScaleInfo.class.getName());
49 startingClasses.add(ResultValueInfo.class.getName());
50
51 String contextFile = "ks-lrc-dictionary-context";
52 String outFile = "target/" + contextFile + ".txt";
53 DictionaryDiscrepencyTesterHelper helper = new DictionaryDiscrepencyTesterHelper(
54 outFile, startingClasses, contextFile + ".xml", false);
55 helper.setPrintDescrepenciesOnly(true);
56 List<String> errors = helper.doTest();
57 if (errors.size() > 0) {
58 fail("failed dictionary validation:\n" + formatAsString(errors));
59 }
60
61 }
62 }