View Javadoc

1   package org.kuali.student.lum.course.service.impl;
2   
3   import org.junit.Test;
4   import org.kuali.student.r1.common.dictionary.service.impl.DictionaryTesterHelper;
5   import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
6   import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
7   import org.kuali.student.r2.lum.lrc.dto.ResultValueRangeInfo;
8   import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
9   
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 TestLrcDictionary
17  {
18  
19   @Test
20   public void testLoadLrcDictionary ()
21   {
22    Set<String> startingClasses = new LinkedHashSet ();
23    startingClasses.add (ResultScaleInfo.class.getName ());
24    startingClasses.add (ResultValueInfo.class.getName ());
25    startingClasses.add (ResultValueRangeInfo.class.getName ());
26    startingClasses.add (ResultValuesGroupInfo.class.getName ());
27    String contextFile = "ks-lrc-dictionary-context";
28    String outFile = "target/" + contextFile + ".txt";
29    DictionaryTesterHelper helper = new DictionaryTesterHelper (outFile,
30                                                                startingClasses,
31                                                                contextFile
32                                                               + ".xml",
33                                                                false);
34    List<String> errors = helper.doTest ();
35    if (errors.size () > 0)
36    {
37     fail ("failed dictionary validation:\n" + formatAsString (errors));
38    }
39   }
40  
41   private String formatAsString (List<String> errors)
42   {
43    int i = 0;
44    StringBuilder builder = new StringBuilder ();
45    for (String error : errors)
46    {
47     i ++;
48     builder.append (i + ". " + error + "\n");
49    }
50    return builder.toString ();
51   }
52  
53  
54   
55  }