Clover Coverage Report - Kuali Student 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 11:14:35 EDT
26   73   4   8.67
2   67   0.15   3
3     1.33  
1    
 
  TestCluSetInfoDictionary       Line # 18 26 0% 4 9 71% 0.7096774
 
  (2)
 
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  1 toggle @Test
22    public void testLoadCluSetInfoDictionary ()
23    {
24  1 Set<String> startingClasses = new LinkedHashSet ();
25  1 startingClasses.add (CluSetInfo.class.getName ());
26  1 String contextFile = "ks-cluSetInfo-dictionary-context";
27  1 String outFile = "target/" + contextFile + ".txt";
28  1 DictionaryTesterHelper helper = new DictionaryTesterHelper (outFile,
29    startingClasses,
30    contextFile
31    + ".xml",
32    false);
33  1 List<String> errors = helper.doTest ();
34  1 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  1 toggle @Test
53    public void testCluSetInfoValidation () throws OperationFailedException
54    {
55  1 ApplicationContext ac = new ClassPathXmlApplicationContext (
56    "classpath:ks-cluSetInfo-dictionary-context.xml");
57  1 System.out.println ("h2. Validation Test");
58  1 DefaultValidatorImpl val = new DefaultValidatorImpl ();
59  1 val.setDateParser (new ServerDateParser ());
60  1 val.setSearchDispatcher (new MockSearchDispatcher ());
61  1 CluSetInfo info = new CluSetInfo ();
62  1 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean (
63    info.getClass ().getName ());
64  1 List<ValidationResultInfo> validationResults = val.validateObject (info, os);
65  1 System.out.println ("h3. With just a blank CluInfo");
66  1 for (ValidationResultInfo vr : validationResults)
67    {
68  2 System.out.println (vr.getElement () + " " + vr.getMessage ());
69    }
70  1 assertEquals (2, validationResults.size ());
71   
72    }
73    }