Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
70   248   15   5
2   161   0.21   14
14     1.07  
1    
 
  HtmlContractWriterTest       Line # 40 70 0% 15 86 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.student.contract.model.util;
17   
18    import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
19    import java.io.File;
20    import java.util.ArrayList;
21    import java.util.Collection;
22    import java.util.List;
23    import org.junit.After;
24    import org.junit.AfterClass;
25    import org.junit.Before;
26    import org.junit.BeforeClass;
27    import org.junit.Test;
28    import org.kuali.student.contract.model.ServiceContractModel;
29    import org.kuali.student.contract.model.impl.ServiceContractModelCache;
30    import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
31    import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
32   
33   
34    import static org.junit.Assert.*;
35   
36    /**
37    *
38    * @author nwright
39    */
 
40    public class HtmlContractWriterTest {
41   
 
42  0 toggle public HtmlContractWriterTest() {
43    }
44   
 
45  0 toggle @BeforeClass
46    public static void setUpClass() throws Exception {
47    }
48   
 
49  0 toggle @AfterClass
50    public static void tearDownClass() throws Exception {
51    }
52   
 
53  0 toggle @Before
54    public void setUp() {
55    }
56   
 
57  0 toggle @After
58    public void tearDown() {
59    }
60    private static final String CORE_DIRECTORY =
61    "C:/svn/ks-1.3/ks-core/ks-core-api/src/main/java";
62    // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
63    private static final String COMMON_DIRECTORY =
64    "C:/svn/ks-1.3/ks-common/ks-common-api/src/main/java";
65    private static final String ENROLL_PROJECT_SOURCE_DIRECTORY =
66    "C:/svn/ks-1.3/ks-enroll/ks-enroll-api/src/main/java";
67    private static final String LUM_DIRECTORY =
68    "C:/svn/ks-1.3/ks-lum/ks-lum-api/src/main/java";
69    private static final String RICE_DIRECTORY =
70    "C:/svn/rice/rice-release-1-0-2-1-br/api/src/main/java";
71    private static final String RICE_CORE_API_DIRECTORY = "C:/svn/rice/trunk/core/api/src/main/java";
72    private static final String RICE_KIM_API_DIRECTORY = "C:/svn/rice/trunk/kim/kim-api/src/main/java";
73    private static final String RICE_LOCATION_API_DIRECTORY = "C:/svn/rice/trunk/location/api/src/main/java";
74    private static final String RICE_KEW_API_DIRECTORY = "C:/svn/rice/trunk/kew/api/src/main/java";
75    private static final String RICE_KEN_API_DIRECTORY = "C:/svn/rice/trunk/ken/api/src/main/java";
76    private static final String RICE_KSB_API_DIRECTORY = "C:/svn/rice/trunk/ksb/api/src/main/java";
77    private static final String RICE_KRMS_API_DIRECTORY = "C:/svn/rice/trunk/krms/api/src/main/java";
78    private static final String RICE_KRMS_IMPL_DIRECTORY = "C:/svn/rice/trunk/krms/impl/src/main/java";
79    private static final String TEST_SOURCE_DIRECTORY =
80    "src/test/java/org/kuali/student/contract/model/test/source";
81    private static final String HTML_CONTRACT_DIRECTORY = "target/html/contract";
82    private static final String HTML_CONTRACT_DIRECTORY_TEST = HTML_CONTRACT_DIRECTORY + "/test";
83    private static final String HTML_CONTRACT_DIRECTORY_ENROLL = HTML_CONTRACT_DIRECTORY + "/enroll";
84    private static final String HTML_CONTRACT_DIRECTORY_RICE = HTML_CONTRACT_DIRECTORY + "/rice";
85    private static final String HTML_CONTRACT_DIRECTORY_PESC = HTML_CONTRACT_DIRECTORY + "/pesc";
86    private static final String RESOURCES_DIRECTORY =
87    // "C:/svn/student/ks-core/ks-core-api/src/main/java";
88    "src/main/resources";
89   
 
90  0 toggle private ServiceContractModel getTestModel() {
91  0 List<String> srcDirs = new ArrayList<String>();
92  0 srcDirs.add(TEST_SOURCE_DIRECTORY);
93    // srcDirs.add(ENROLL_PROJECT_SOURCE_DIRECTORY);
94    // srcDirs.add(CORE_DIRECTORY);
95    // srcDirs.add(COMMON_DIRECTORY);
96    // srcDirs.add(LUM_DIRECTORY);
97  0 ServiceContractModel instance = new ServiceContractModelQDoxLoader(
98    srcDirs);
99  0 return new ServiceContractModelCache(instance);
100   
101    }
102   
 
103  0 toggle private ServiceContractModel getRiceModel() {
104  0 List<String> srcDirs = new ArrayList<String>();
105    // srcDirs.add(TEST_SOURCE_DIRECTORY);
106  0 srcDirs.add(RICE_CORE_API_DIRECTORY);
107  0 srcDirs.add(RICE_KIM_API_DIRECTORY);
108  0 srcDirs.add(RICE_LOCATION_API_DIRECTORY);
109  0 srcDirs.add(RICE_KEW_API_DIRECTORY);
110  0 srcDirs.add(RICE_KEN_API_DIRECTORY);
111  0 srcDirs.add(RICE_KSB_API_DIRECTORY);
112  0 srcDirs.add(RICE_KRMS_API_DIRECTORY);
113  0 srcDirs.add(RICE_KRMS_IMPL_DIRECTORY);
114    // srcDirs.add(CORE_DIRECTORY);
115    // srcDirs.add(COMMON_DIRECTORY);
116    // srcDirs.add(LUM_DIRECTORY);
117  0 ServiceContractModel instance = new ServiceContractModelQDoxLoader(
118    srcDirs, false);
119  0 return new ServiceContractModelCache(instance);
120   
121    }
122   
 
123  0 toggle private ServiceContractModel getEnrollModel() {
124  0 List<String> srcDirs = new ArrayList<String>();
125    // srcDirs.add(TEST_SOURCE_DIRECTORY);
126  0 srcDirs.add(ENROLL_PROJECT_SOURCE_DIRECTORY);
127    // srcDirs.add(CORE_DIRECTORY);
128    // srcDirs.add(COMMON_DIRECTORY);
129    // srcDirs.add(LUM_DIRECTORY);
130  0 ServiceContractModel instance = new ServiceContractModelQDoxLoader(
131    srcDirs);
132  0 return new ServiceContractModelCache(instance);
133   
134    }
135    // pesc stuff
136    private static final String PESC_DIRECTORY =
137    RESOURCES_DIRECTORY + "/pesc";
138    private static final String PESC_CORE_MAIN = PESC_DIRECTORY + "/CoreMain.xsd";
139    private static final String PESC_ACAD_REC = PESC_DIRECTORY + "/AcademicRecord_v1.5.0.xsd";
140    private static final String PESC_COLL_TRANS = PESC_DIRECTORY + "/CollegeTranscript_v1.2.0.xsd";
141   
 
142  0 toggle private ServiceContractModel getPescModel() {
143  0 List<String> xsdFileNames = new ArrayList();
144    // xsdFileNames.add(PESC_CORE_MAIN);
145    // xsdFileNames.add(PESC_ACAD_REC);
146  0 xsdFileNames.add(PESC_COLL_TRANS);
147  0 ServiceContractModel instance = new ServiceContractModelPescXsdLoader(xsdFileNames);
148  0 instance = new ServiceContractModelCache(instance);
149  0 validate(instance);
150  0 return instance;
151    }
152   
153   
 
154  0 toggle private void validate(ServiceContractModel model) {
155  0 Collection<String> errors =
156    new ServiceContractModelValidator(model).validate();
157  0 if (errors.size() > 0) {
158  0 StringBuilder buf = new StringBuilder();
159  0 buf.append(errors.size()).append(" errors found while validating the data.");
160  0 int cnt = 0;
161  0 for (String msg : errors) {
162  0 cnt++;
163  0 buf.append("\n");
164  0 buf.append("*error*").append(cnt).append(":").append(msg);
165    }
166   
167  0 fail(buf.toString());
168    }
169    }
170   
171    /**
172    * Test of run
173    */
174    // @Test
 
175  0 toggle public void testRunPesc() {
176  0 ServiceContractModel model = null;
177  0 HtmlContractWriter writer = null;
178   
179  0 model = this.getPescModel();
180  0 this.validate(model);
181  0 writer = new HtmlContractWriter(HTML_CONTRACT_DIRECTORY_PESC, model);
182  0 writer.write();
183   
184  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_PESC + "/" + "index.html").exists());
185    }
186   
187    /**
188    * Test of run
189    */
 
190  0 toggle @Test
191    public void testTestRun () {
192  0 ServiceContractModel model = null;
193  0 HtmlContractWriter writer = null;
194   
195  0 model = this.getTestModel();
196  0 this.validate(model);
197  0 writer = new HtmlContractWriter(HTML_CONTRACT_DIRECTORY_TEST, model);
198  0 writer.write();
199   
200  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "index.html").exists());
201  0 assertTrue(
202    new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "LprService.html").exists());
203  0 assertTrue(
204    new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "LprInfo.html").exists());
205  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "ContextInfo.html").exists());
206  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "RichTextInfo.html").exists());
207  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "MetaInfo.html").exists());
208   
209  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "StateService.html").exists());
210  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "StateInfo.html").exists());
211   
212  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "TypeService.html").exists());
213  0 assertTrue(new File(HTML_CONTRACT_DIRECTORY_TEST + "/" + "TypeInfo.html").exists());
214    }
215   
216   
217    /**
218    * Test of run
219    */
220    // @Test
 
221  0 toggle public void testEnrollRun () {
222  0 ServiceContractModel model = null;
223  0 HtmlContractWriter writer = null;
224   
225  0 model = this.getEnrollModel();
226  0 this.validate(model);
227  0 writer = new HtmlContractWriter(HTML_CONTRACT_DIRECTORY_ENROLL, model);
228  0 writer.write();
229   
230    // assertTrue(new File(HTML_CONTRACT_DIRECTORY_ENROLL + "/" + "index.html").exists());
231    }
232   
233    /**
234    * Test of run
235    */
236    // @Test
 
237  0 toggle public void testRiceRun () {
238  0 ServiceContractModel model = null;
239  0 HtmlContractWriter writer = null;
240   
241  0 model = this.getRiceModel();
242  0 this.validate(model);
243  0 writer = new HtmlContractWriter(HTML_CONTRACT_DIRECTORY_RICE, model);
244  0 writer.write();
245   
246    // assertTrue(new File(HTML_CONTRACT_DIRECTORY_ENROLL + "/" + "index.html").exists());
247    }
248    }