Clover Coverage Report - Kuali Student 1.2-M1-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Mar 4 2011 04:03:38 EST
../../../../../../img/srcFileCovDistChart8.png 32% of files have more coverage
33   101   5   11
2   90   0.15   3
3     1.67  
1    
 
  SearchConfigTesterHelper       Line # 21 33 0% 5 10 73.7% 0.7368421
 
  (1)
 
1    package org.kuali.student.core.dictionary.service;
2   
3    import java.io.File;
4    import java.io.FileNotFoundException;
5    import java.io.FileOutputStream;
6    import java.io.OutputStream;
7    import java.io.PrintStream;
8    import static org.junit.Assert.*;
9    import java.util.Date;
10    import java.util.List;
11    import java.util.Map;
12   
13    import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo;
14    import org.kuali.student.common.search.dto.SearchResultTypeInfo;
15    import org.kuali.student.common.search.dto.SearchTypeInfo;
16    import org.kuali.student.common.search.service.impl.SearchConfigFormatter;
17    import org.kuali.student.common.search.service.impl.SearchConfigValidator;
18    import org.springframework.context.ApplicationContext;
19    import org.springframework.context.support.ClassPathXmlApplicationContext;
20   
 
21    public class SearchConfigTesterHelper
22    {
23   
24    private String outputFileName;
25    private File file;
26    private OutputStream os;
27    private PrintStream out;
28    private String searchConfigFileName;
29    private String projectLocation;
30    private Map<String, SearchTypeInfo> searchInfoTypeMap;
31    private Map<String, SearchCriteriaTypeInfo> searchCriteriaTypeMap;
32    private Map<String, SearchResultTypeInfo> searchResultTypeInfoMap;
33    private Map<String, String> queryMap;
34   
 
35  5 toggle public SearchConfigTesterHelper (String outputFileName,
36    String projectLocation,
37    String searchConfigFileName)
38    {
39  5 this.outputFileName = outputFileName;
40  5 this.projectLocation = projectLocation;
41  5 this.searchConfigFileName = searchConfigFileName;
42    // get printstream from file
43  5 this.file = new File (this.outputFileName);
44  5 try
45    {
46  5 os = new FileOutputStream (file, false);
47    }
48    catch (FileNotFoundException ex)
49    {
50  0 throw new IllegalArgumentException (ex);
51    }
52  5 this.out = new PrintStream (os);
53    }
54   
 
55  5 toggle public void doTest ()
56    {
57  5 ApplicationContext ac = new ClassPathXmlApplicationContext (
58    "classpath:" + searchConfigFileName);
59  5 searchInfoTypeMap = ac.getBeansOfType (SearchTypeInfo.class);
60  5 searchCriteriaTypeMap = ac.getBeansOfType (SearchCriteriaTypeInfo.class);
61  5 searchResultTypeInfoMap = ac.getBeansOfType (SearchResultTypeInfo.class);
62  5 queryMap = (Map<String, String>) ac.getBean ("queryMap");
63   
64  5 out.println ("(!) This page was automatically generated on " + new Date ());
65  5 out.println ("DO NOT UPDATE MANUALLY!");
66  5 out.println ("");
67  5 out.print ("This page represents a formatted view of [" + searchConfigFileName
68    + "|https://test.kuali.org/svn/student/trunk/" + projectLocation
69    + "/src/main/resources/"
70    + searchConfigFileName + "]");
71  5 out.println ("");
72  5 out.println ("----");
73  5 out.println ("{toc}");
74  5 out.println ("----");
75  5 SearchConfigValidator validator = new SearchConfigValidator (searchInfoTypeMap,
76    queryMap);
77   
78  5 List<String> errors = validator.validate ();
79  5 if (errors.size () > 0)
80    {
81  0 fail (searchConfigFileName + " failed search config validation:\n"
82    + this.formatAsString (errors));
83    }
84   
85  5 SearchConfigFormatter formatter = new SearchConfigFormatter (searchInfoTypeMap,
86    queryMap);
87  5 out.println (formatter.formatForWiki ());
88    }
89   
 
90  0 toggle private String formatAsString (List<String> discrepancies)
91    {
92  0 int i = 0;
93  0 StringBuilder builder = new StringBuilder ();
94  0 for (String discrep : discrepancies)
95    {
96  0 i ++;
97  0 builder.append (i + ". " + discrep + "\n");
98    }
99  0 return builder.toString ();
100    }
101    }