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 java.io.File; |
19 |
|
import java.util.ArrayList; |
20 |
|
import java.util.Collection; |
21 |
|
import java.util.List; |
22 |
|
import org.junit.After; |
23 |
|
import org.junit.AfterClass; |
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.BeforeClass; |
26 |
|
import org.junit.Test; |
27 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
28 |
|
import org.kuali.student.contract.model.impl.ServiceContractModelCache; |
29 |
|
import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader; |
30 |
|
import org.kuali.student.contract.model.validation.ServiceContractModelValidator; |
31 |
|
|
32 |
|
|
33 |
|
import static org.junit.Assert.*; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@author |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 9 |
Complexity Density: 0.33 |
|
39 |
|
public class XmlKradBaseDictionaryCreatorTest { |
40 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
41 |
0
|
public XmlKradBaseDictionaryCreatorTest() {... |
42 |
|
} |
43 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
44 |
0
|
@BeforeClass... |
45 |
|
public static void setUpClass() throws Exception { |
46 |
|
} |
47 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
48 |
0
|
@AfterClass... |
49 |
|
public static void tearDownClass() throws Exception { |
50 |
|
} |
51 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
52 |
0
|
@Before... |
53 |
|
public void setUp() { |
54 |
|
} |
55 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
56 |
0
|
@After... |
57 |
|
public void tearDown() { |
58 |
|
} |
59 |
|
private static final String CORE_DIRECTORY = |
60 |
|
"C:/svn/ks-1.3/ks-core/ks-core-api/src/main/java"; |
61 |
|
|
62 |
|
private static final String COMMON_DIRECTORY = |
63 |
|
"C:/svn/ks-1.3/ks-common/ks-common-api/src/main/java"; |
64 |
|
private static final String ENROLL_DIRECTORY = |
65 |
|
"C:/svn/ks-1.3/ks-enroll/ks-enroll-api/src/main/java"; |
66 |
|
private static final String LUM_DIRECTORY = |
67 |
|
"C:/svn/ks-1.3/ks-lum/ks-lum-api/src/main/java"; |
68 |
|
private static final String RICE_DIRECTORY = |
69 |
|
"C:/svn/rice/rice-release-1-0-2-1-br/api/src/main/java"; |
70 |
|
private static final String TEST_SOURCE_DIRECTORY = |
71 |
|
"src/test/java/org/kuali/student/contract/model/test/source"; |
72 |
|
private static final String XML_DICTIONARY_DIRECTORY = "target/xml/dictionary"; |
73 |
|
private static final String RESOURCES_DIRECTORY = |
74 |
|
|
75 |
|
"src/main/resources"; |
76 |
|
private static final String PESC_CORE_MAIN = RESOURCES_DIRECTORY |
77 |
|
+ "/CoreMain_v1.8.0.xsd"; |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
79 |
0
|
private ServiceContractModel getModel() {... |
80 |
0
|
List<String> srcDirs = new ArrayList<String>(); |
81 |
|
|
82 |
0
|
srcDirs.add(ENROLL_DIRECTORY); |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
0
|
ServiceContractModel instance = new ServiceContractModelQDoxLoader( |
87 |
|
srcDirs); |
88 |
0
|
return new ServiceContractModelCache(instance); |
89 |
|
|
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
92 |
0
|
private void validate(ServiceContractModel model) {... |
93 |
0
|
Collection<String> errors = |
94 |
|
new ServiceContractModelValidator(model).validate(); |
95 |
0
|
if (errors.size() > 0) { |
96 |
0
|
StringBuilder buf = new StringBuilder(); |
97 |
0
|
buf.append(errors.size() |
98 |
|
+ " errors found while validating the data."); |
99 |
0
|
int cnt = 0; |
100 |
0
|
for (String msg : errors) { |
101 |
0
|
cnt++; |
102 |
0
|
buf.append("\n"); |
103 |
0
|
buf.append("*error*" + cnt + ":" + msg); |
104 |
|
} |
105 |
|
|
106 |
0
|
fail(buf.toString()); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
4
-
|
|
113 |
0
|
@Test... |
114 |
|
public void testRun() { |
115 |
0
|
ServiceContractModel model = null; |
116 |
0
|
XmlKradBaseDictionaryCreator writer = null; |
117 |
|
|
118 |
0
|
model = this.getModel(); |
119 |
0
|
this.validate(model); |
120 |
0
|
String xmlObject = null; |
121 |
|
|
122 |
0
|
xmlObject = "atpInfo"; |
123 |
0
|
writer = new XmlKradBaseDictionaryCreator(XML_DICTIONARY_DIRECTORY, model, xmlObject); |
124 |
0
|
writer.write(); |
125 |
0
|
assertTrue(new File(XML_DICTIONARY_DIRECTORY + "/" + "ks-" + xmlObject + "-dictionary.xml").exists()); |
126 |
|
|
127 |
0
|
xmlObject = "atpInfo"; |
128 |
0
|
writer = new XmlKradBaseDictionaryCreator(XML_DICTIONARY_DIRECTORY, model, xmlObject); |
129 |
0
|
writer.write(); |
130 |
0
|
assertTrue(new File(XML_DICTIONARY_DIRECTORY + "/" + "ks-" + xmlObject + "-dictionary.xml").exists()); |
131 |
|
|
132 |
|
} |
133 |
|
} |