Clover Coverage Report - Kuali Student 1.1.0-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 15 2011 04:04:07 EST
38   104   5   12.67
2   89   0.13   3
3     1.67  
1    
 
  TestProgramInfoDictionary       Line # 28 38 0% 5 10 76.7% 0.76744187
 
  (2)
 
1    package org.kuali.student.lum.program.service.impl;
2   
3    import static org.junit.Assert.assertEquals;
4    import static org.junit.Assert.fail;
5   
6    import java.util.LinkedHashSet;
7    import java.util.List;
8    import java.util.Set;
9   
10    import org.junit.Test;
11    import org.kuali.student.common.validator.DefaultValidatorImpl;
12    import org.kuali.student.common.validator.ServerDateParser;
13    import org.kuali.student.common.validator.ValidatorFactory;
14    import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition;
15    import org.kuali.student.core.dictionary.service.impl.DictionaryTesterHelper;
16    import org.kuali.student.core.exceptions.OperationFailedException;
17    import org.kuali.student.core.validation.dto.ValidationResultInfo;
18    import org.kuali.student.lum.course.service.impl.MockSearchDispatcher;
19    import org.kuali.student.lum.program.dto.CoreProgramInfo;
20    import org.kuali.student.lum.program.dto.CredentialProgramInfo;
21    import org.kuali.student.lum.program.dto.MajorDisciplineInfo;
22    import org.kuali.student.lum.program.dto.MinorDisciplineInfo;
23    import org.kuali.student.lum.program.dto.ProgramRequirementInfo;
24    import org.kuali.student.lum.program.service.assembler.MajorDisciplineDataGenerator;
25    import org.springframework.context.ApplicationContext;
26    import org.springframework.context.support.ClassPathXmlApplicationContext;
27   
 
28    public class TestProgramInfoDictionary {
29   
 
30  1 toggle @Test
31    public void testLoadProgramInfoDictionary() {
32  1 Set<String> startingClasses = new LinkedHashSet();
33  1 startingClasses.add(MajorDisciplineInfo.class.getName ());
34  1 startingClasses.add(CoreProgramInfo.class.getName ());
35  1 startingClasses.add(MinorDisciplineInfo.class.getName ());
36  1 startingClasses.add(CredentialProgramInfo.class.getName ());
37  1 startingClasses.add(ProgramRequirementInfo.class.getName ());
38  1 String contextFile = "ks-programInfo-dictionary-context";
39  1 String outFile = "target/" + contextFile + ".txt";
40  1 DictionaryTesterHelper helper = new DictionaryTesterHelper(outFile,
41    startingClasses,
42    contextFile
43    + ".xml",
44    true);
45  1 List<String> errors = helper.doTest ();
46  1 if (errors.size () > 0)
47    {
48  0 fail ("failed dictionary validation:\n" + formatAsString (errors));
49    }
50    }
51   
 
52  0 toggle private String formatAsString (List<String> errors)
53    {
54  0 int i = 0;
55  0 StringBuilder builder = new StringBuilder ();
56  0 for (String error : errors)
57    {
58  0 i ++;
59  0 builder.append (i + ". " + error + "\n");
60    }
61  0 return builder.toString ();
62    }
63   
64   
 
65  1 toggle @Test
66    public void testMajorDisciplineInfoValidation() throws
67    OperationFailedException {
68  1 System.out.println("h1. Validation results");
69  1 ApplicationContext ac = new ClassPathXmlApplicationContext(
70    "classpath:ks-programInfo-dictionary-context.xml");
71  1 DefaultValidatorImpl val = new DefaultValidatorImpl();
72  1 val.setValidatorFactory(new ValidatorFactory());
73  1 val.setDateParser(new ServerDateParser());
74  1 val.setSearchDispatcher(new MockSearchDispatcher());
75  1 MajorDisciplineInfo info = new MajorDisciplineInfo();
76  1 ObjectStructureDefinition os = (ObjectStructureDefinition) ac.getBean(
77    info.getClass().getName());
78  1 List<ValidationResultInfo> validationResults = val.validateObject(info, os);
79  1 System.out.println("h2. with just a blank record");
80  1 for (ValidationResultInfo vr : validationResults) {
81  5 System.out.println(vr.getElement() + " " + vr.getMessage());
82    }
83    // /credentialProgramId validation.required
84    // /universityClassification validation.required
85    // /longTitle validation.required
86    // /type validation.required
87    // /state validation.required
88  1 assertEquals(5, validationResults.size());
89   
90  1 try {
91  1 info =
92    new MajorDisciplineDataGenerator().getMajorDisciplineInfoTestData();
93    }
94    catch (Exception ex) {
95  0 throw new RuntimeException(ex);
96    }
97  1 validationResults = val.validateObject(info, os);
98  1 System.out.println("h2. with generated data");
99  1 for (ValidationResultInfo vr : validationResults) {
100  18 System.out.println(vr.getElement() + " " + vr.getMessage());
101    }
102    //assertEquals(4, validationResults.size());
103    }
104    }