Clover Coverage Report - Kuali Student 1.2-M1-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Mar 4 2011 04:03:38 EST
59   115   5   14.75
2   105   0.08   4
4     1.25  
1    
 
  TestStatementDictionary       Line # 22 59 0% 5 11 83.1% 0.83076924
 
  (3)
 
1    package org.kuali.student.core.dictionary.service;
2   
3    import java.util.Arrays;
4    import java.util.LinkedHashSet;
5    import java.util.List;
6    import java.util.Set;
7    import org.junit.Test;
8    import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
9    import org.kuali.student.common.dictionary.service.impl.DictionaryTesterHelper;
10    import org.kuali.student.common.exceptions.OperationFailedException;
11    import org.kuali.student.common.validation.dto.ValidationResultInfo;
12    import org.kuali.student.common.validator.DefaultValidatorImpl;
13    import org.kuali.student.common.validator.ServerDateParser;
14    import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
15    import org.kuali.student.core.statement.dto.ReqComponentInfo;
16    import org.kuali.student.core.statement.dto.StatementInfo;
17    import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
18    import org.springframework.context.ApplicationContext;
19    import org.springframework.context.support.ClassPathXmlApplicationContext;
20    import static org.junit.Assert.*;
21   
 
22    public class TestStatementDictionary {
23   
 
24  1 toggle @Test
25    public void testLoadStatementInfoDictionary() {
26  1 System.out.println ("testing statement dictionary");
27  1 Set<String> startingClasses = new LinkedHashSet();
28  1 startingClasses.add(StatementInfo.class.getName ());
29  1 startingClasses.add(ReqComponentInfo.class.getName ());
30  1 startingClasses.add(StatementTreeViewInfo.class.getName ());
31  1 String contextFile = "ks-statement-dictionary-context";
32  1 String outFile = "target/" + contextFile + ".txt";
33  1 DictionaryTesterHelper helper = new DictionaryTesterHelper(outFile,
34    startingClasses, contextFile + ".xml", false);
35  1 List<String> errors = helper.doTest ();
36  1 if (errors.size () > 0)
37    {
38  0 fail ("failed dictionary validation:\n" + formatAsString (errors));
39    }
40    }
41   
 
42  0 toggle private String formatAsString (List<String> errors)
43    {
44  0 int i = 0;
45  0 StringBuilder builder = new StringBuilder ();
46  0 for (String error : errors)
47    {
48  0 i ++;
49  0 builder.append (i + ". " + error + "\n");
50    }
51  0 return builder.toString ();
52    }
53   
54   
 
55  1 toggle @Test
56    public void testStatementInfoValidation() throws OperationFailedException {
57  1 ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:ks-statement-dictionary-context.xml");
58  1 System.out.println("h2. Validation Test");
59  1 DefaultValidatorImpl val = new DefaultValidatorImpl();
60  1 val.setDateParser(new ServerDateParser());
61  1 val.setSearchDispatcher(new MockSearchDispatcher());
62  1 StatementInfo info = new StatementInfo();
63  1 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean(info.getClass().getName());
64  1 List<ValidationResultInfo> validationResults = val.validateObject(info, os);
65  1 System.out.println("h3. With just a blank StatementInfo");
66  1 for (ValidationResultInfo vr : validationResults)
67    {
68  1 System.out.println (vr.getElement () + " " + vr.getMessage ());
69    }
70  1 assertEquals(1, validationResults.size());
71    }
72   
 
73  1 toggle @Test
74    public void testRequirementComponentInfoValidation() throws OperationFailedException {
75  1 ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:ks-statement-dictionary-context.xml");
76  1 System.out.println("h2. Validation Test");
77  1 DefaultValidatorImpl val = new DefaultValidatorImpl();
78  1 val.setDateParser(new ServerDateParser());
79  1 val.setSearchDispatcher(new MockSearchDispatcher());
80  1 ReqComponentInfo info = new ReqComponentInfo();
81  1 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean(info.getClass().getName());
82  1 List<ValidationResultInfo> validationResults = val.validateObject(info, os);
83  1 System.out.println("h3. With just a blank ReqComponentInfo");
84  1 for (ValidationResultInfo vr : validationResults)
85    {
86  0 System.out.println (vr.getElement () + " " + vr.getMessage ());
87    }
88  1 assertEquals(0, validationResults.size());
89   
90  1 ReqCompFieldInfo fieldInfo = new ReqCompFieldInfo ();
91  1 fieldInfo.setType ("kuali.reqComponent.field.type.gradeType.id");
92  1 fieldInfo.setValue ("kuali.resultComponent.grade.letter");
93  1 info.setReqCompFields (Arrays.asList (fieldInfo));
94  1 validationResults = val.validateObject(info, os);
95  1 System.out.println("h3. With just a blank ReqComponentInfo");
96  1 for (ValidationResultInfo vr : validationResults)
97    {
98  0 System.out.println (vr.getElement () + " " + vr.getMessage ());
99    }
100  1 assertEquals(0, validationResults.size());
101   
102  1 fieldInfo = new ReqCompFieldInfo ();
103  1 fieldInfo.setType ("kuali.reqComponent.field.type.gradeType.id");
104  1 fieldInfo.setValue ("bad with an embedded space in value");
105  1 info.setReqCompFields (Arrays.asList (fieldInfo));
106  1 validationResults = val.validateObject(info, os);
107  1 System.out.println("h3. With just a blank ReqComponentInfo");
108  1 for (ValidationResultInfo vr : validationResults)
109    {
110  1 System.out.println (vr.getElement () + " " + vr.getMessage ());
111    }
112  1 assertEquals(1, validationResults.size());
113   
114    }
115    }