Clover Coverage Report - KS LUM Impl 1.3.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
26   73   4   8.67
2   67   0.15   3
3     1.33  
1    
 
  TestCluSetInfoDictionary       Line # 18 26 0% 4 31 0% 0.0
 
No Tests
 
1    package org.kuali.student.lum.course.service.impl;
2   
3    import java.util.LinkedHashSet;
4    import java.util.List;
5    import java.util.Set;
6    import org.junit.Test;
7    import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
8    import org.kuali.student.common.dictionary.service.impl.DictionaryTesterHelper;
9    import org.kuali.student.common.exceptions.OperationFailedException;
10    import org.kuali.student.common.validation.dto.ValidationResultInfo;
11    import org.kuali.student.common.validator.DefaultValidatorImpl;
12    import org.kuali.student.common.validator.ServerDateParser;
13    import org.kuali.student.lum.lu.dto.CluSetInfo;
14    import org.springframework.context.ApplicationContext;
15    import org.springframework.context.support.ClassPathXmlApplicationContext;
16    import static org.junit.Assert.*;
17   
 
18    public class TestCluSetInfoDictionary
19    {
20   
 
21  0 toggle @Test
22    public void testLoadCluSetInfoDictionary ()
23    {
24  0 Set<String> startingClasses = new LinkedHashSet ();
25  0 startingClasses.add (CluSetInfo.class.getName ());
26  0 String contextFile = "ks-cluSetInfo-dictionary-context";
27  0 String outFile = "target/" + contextFile + ".txt";
28  0 DictionaryTesterHelper helper = new DictionaryTesterHelper (outFile,
29    startingClasses,
30    contextFile
31    + ".xml",
32    false);
33  0 List<String> errors = helper.doTest ();
34  0 if (errors.size () > 0)
35    {
36  0 fail ("failed dictionary validation:\n" + formatAsString (errors));
37    }
38    }
39   
 
40  0 toggle private String formatAsString (List<String> errors)
41    {
42  0 int i = 0;
43  0 StringBuilder builder = new StringBuilder ();
44  0 for (String error : errors)
45    {
46  0 i ++;
47  0 builder.append (i + ". " + error + "\n");
48    }
49  0 return builder.toString ();
50    }
51   
 
52  0 toggle @Test
53    public void testCluSetInfoValidation () throws OperationFailedException
54    {
55  0 ApplicationContext ac = new ClassPathXmlApplicationContext (
56    "classpath:ks-cluSetInfo-dictionary-context.xml");
57  0 System.out.println ("h2. Validation Test");
58  0 DefaultValidatorImpl val = new DefaultValidatorImpl ();
59  0 val.setDateParser (new ServerDateParser ());
60  0 val.setSearchDispatcher (new MockSearchDispatcher ());
61  0 CluSetInfo info = new CluSetInfo ();
62  0 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean (
63    info.getClass ().getName ());
64  0 List<ValidationResultInfo> validationResults = val.validateObject (info, os);
65  0 System.out.println ("h3. With just a blank CluInfo");
66  0 for (ValidationResultInfo vr : validationResults)
67    {
68  0 System.out.println (vr.getElement () + " " + vr.getMessage ());
69    }
70  0 assertEquals (2, validationResults.size ());
71   
72    }
73    }