1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
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 |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 86 (86) |
Complexity: 15 |
Complexity Density: 0.21 |
|
40 |
|
public class HtmlContractWriterTest { |
41 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
42 |
0
|
public HtmlContractWriterTest() {... |
43 |
|
} |
44 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
45 |
0
|
@BeforeClass... |
46 |
|
public static void setUpClass() throws Exception { |
47 |
|
} |
48 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
49 |
0
|
@AfterClass... |
50 |
|
public static void tearDownClass() throws Exception { |
51 |
|
} |
52 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
53 |
0
|
@Before... |
54 |
|
public void setUp() { |
55 |
|
} |
56 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
57 |
0
|
@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 |
|
|
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 |
|
|
88 |
|
"src/main/resources"; |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
90 |
0
|
private ServiceContractModel getTestModel() {... |
91 |
0
|
List<String> srcDirs = new ArrayList<String>(); |
92 |
0
|
srcDirs.add(TEST_SOURCE_DIRECTORY); |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
0
|
ServiceContractModel instance = new ServiceContractModelQDoxLoader( |
98 |
|
srcDirs); |
99 |
0
|
return new ServiceContractModelCache(instance); |
100 |
|
|
101 |
|
} |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
103 |
0
|
private ServiceContractModel getRiceModel() {... |
104 |
0
|
List<String> srcDirs = new ArrayList<String>(); |
105 |
|
|
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 |
|
|
115 |
|
|
116 |
|
|
117 |
0
|
ServiceContractModel instance = new ServiceContractModelQDoxLoader( |
118 |
|
srcDirs, false); |
119 |
0
|
return new ServiceContractModelCache(instance); |
120 |
|
|
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
123 |
0
|
private ServiceContractModel getEnrollModel() {... |
124 |
0
|
List<String> srcDirs = new ArrayList<String>(); |
125 |
|
|
126 |
0
|
srcDirs.add(ENROLL_PROJECT_SOURCE_DIRECTORY); |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
0
|
ServiceContractModel instance = new ServiceContractModelQDoxLoader( |
131 |
|
srcDirs); |
132 |
0
|
return new ServiceContractModelCache(instance); |
133 |
|
|
134 |
|
} |
135 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
142 |
0
|
private ServiceContractModel getPescModel() {... |
143 |
0
|
List<String> xsdFileNames = new ArrayList(); |
144 |
|
|
145 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
154 |
0
|
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 |
|
|
173 |
|
|
174 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
4
-
|
|
175 |
0
|
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 |
|
|
189 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
4
-
|
|
190 |
0
|
@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 |
|
|
219 |
|
|
220 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4
-
|
|
221 |
0
|
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 |
|
|
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4
-
|
|
237 |
0
|
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 |
|
|
247 |
|
} |
248 |
|
} |