Clover Coverage Report - Kuali Student 1.1.0-M10-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Dec 17 2010 05:04:51 EST
29   71   4   9.67
2   64   0.14   3
3     1.33  
1    
 
  TestAtpDictionary       Line # 20 29 0% 4 9 73.5% 0.7352941
 
  (2)
 
1    package org.kuali.student.core.dictionary.service;
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.validator.DefaultValidatorImpl;
8    import org.kuali.student.common.validator.ServerDateParser;
9    import org.kuali.student.core.atp.dto.AtpInfo;
10    import org.kuali.student.core.atp.dto.DateRangeInfo;
11    import org.kuali.student.core.atp.dto.MilestoneInfo;
12    import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition;
13    import org.kuali.student.core.dictionary.service.impl.DictionaryTesterHelper;
14    import org.kuali.student.core.exceptions.OperationFailedException;
15    import org.kuali.student.core.validation.dto.ValidationResultInfo;
16    import org.springframework.context.ApplicationContext;
17    import org.springframework.context.support.ClassPathXmlApplicationContext;
18    import static org.junit.Assert.*;
19   
 
20    public class TestAtpDictionary {
21   
 
22  1 toggle @Test
23    public void testLoadAtpDictionary() {
24  1 System.out.println ("testing atp dictionary");
25  1 Set<String> startingClasses = new LinkedHashSet();
26  1 startingClasses.add(AtpInfo.class.getName ());
27  1 startingClasses.add(MilestoneInfo.class.getName ());
28  1 startingClasses.add(DateRangeInfo.class.getName ());
29  1 String contextFile = "ks-atp-dictionary-context";
30  1 String outFile = "target/" + contextFile + ".txt";
31  1 DictionaryTesterHelper helper = new DictionaryTesterHelper(outFile,
32    startingClasses, contextFile + ".xml", 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   
 
53  1 toggle @Test
54    public void testAtpInfoValidation() throws OperationFailedException {
55  1 ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:ks-atp-dictionary-context.xml");
56  1 System.out.println("h2. Validation Test");
57  1 DefaultValidatorImpl val = new DefaultValidatorImpl();
58  1 val.setDateParser(new ServerDateParser());
59  1 val.setSearchDispatcher(new MockSearchDispatcher());
60  1 AtpInfo info = new AtpInfo ();
61  1 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean(info.getClass().getName());
62  1 List<ValidationResultInfo> validationResults = val.validateObject(info, os);
63  1 System.out.println("h3. With just a blank StatementInfo");
64  1 for (ValidationResultInfo vr : validationResults)
65    {
66  3 System.out.println (vr.getElement () + " " + vr.getMessage ());
67    }
68  1 assertEquals(3, validationResults.size());
69    }
70   
71    }