1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package org.kuali.student.contract.model.impl; |
6 |
|
|
7 |
|
import org.kuali.student.contract.model.MessageStructure; |
8 |
|
import org.kuali.student.contract.model.Service; |
9 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
10 |
|
import org.kuali.student.contract.model.ServiceMethod; |
11 |
|
import org.kuali.student.contract.model.ServiceMethodParameter; |
12 |
|
import org.kuali.student.contract.model.XmlType; |
13 |
|
import org.kuali.student.contract.model.util.MessageStructureDumper; |
14 |
|
import org.kuali.student.contract.model.validation.ServiceContractModelValidator; |
15 |
|
import java.util.ArrayList; |
16 |
|
import java.util.Collection; |
17 |
|
import java.util.List; |
18 |
|
import org.junit.After; |
19 |
|
import org.junit.AfterClass; |
20 |
|
import org.junit.Before; |
21 |
|
import org.junit.BeforeClass; |
22 |
|
import org.junit.Test; |
23 |
|
import static org.junit.Assert.*; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 81 (81) |
Complexity: 17 |
Complexity Density: 0.28 |
|
29 |
|
public class ServiceContractModelPescXsdLoaderTest { |
30 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
31 |
0
|
public ServiceContractModelPescXsdLoaderTest() {... |
32 |
|
} |
33 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
34 |
0
|
@BeforeClass... |
35 |
|
public static void setUpClass() throws Exception { |
36 |
|
} |
37 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
38 |
0
|
@AfterClass... |
39 |
|
public static void tearDownClass() throws Exception { |
40 |
|
} |
41 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
42 |
0
|
@Before... |
43 |
|
public void setUp() { |
44 |
|
} |
45 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
46 |
0
|
@After... |
47 |
|
public void tearDown() { |
48 |
|
} |
49 |
|
private static final String RESOURCES_DIRECTORY = |
50 |
|
|
51 |
|
"src/main/resources"; |
52 |
|
private static final String PESC_DIRECTORY = |
53 |
|
RESOURCES_DIRECTORY + "/pesc"; |
54 |
|
private static final String PESC_CORE_MAIN = PESC_DIRECTORY + "/CoreMain.xsd"; |
55 |
|
private static final String PESC_ACAD_REC = PESC_DIRECTORY + "/AcademicRecord_v1.5.0.xsd"; |
56 |
|
private static final String PESC_COLL_TRANS = PESC_DIRECTORY + "/CollegeTranscript_v1.2.0.xsd"; |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
58 |
0
|
private ServiceContractModel getModel() {... |
59 |
0
|
List<String> xsdFileNames = new ArrayList(); |
60 |
|
|
61 |
|
|
62 |
0
|
xsdFileNames.add(PESC_COLL_TRANS); |
63 |
0
|
ServiceContractModel instance = new ServiceContractModelPescXsdLoader(xsdFileNames); |
64 |
0
|
instance = new ServiceContractModelCache(instance); |
65 |
0
|
validate(instance); |
66 |
0
|
return instance; |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
69 |
0
|
private String dump(ServiceMethod method) {... |
70 |
0
|
StringBuilder bldr = new StringBuilder(); |
71 |
0
|
bldr.append(method.getName()); |
72 |
0
|
String comma = ""; |
73 |
0
|
bldr.append("("); |
74 |
0
|
for (ServiceMethodParameter param : method.getParameters()) { |
75 |
0
|
bldr.append(comma); |
76 |
0
|
comma = ", "; |
77 |
0
|
bldr.append(param.getType()); |
78 |
0
|
bldr.append(" "); |
79 |
0
|
bldr.append(param.getName()); |
80 |
|
} |
81 |
0
|
bldr.append(")"); |
82 |
0
|
return bldr.toString(); |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
85 |
0
|
private void validate(ServiceContractModel model) {... |
86 |
0
|
Collection<String> errors = |
87 |
|
new ServiceContractModelValidator(model).validate(); |
88 |
0
|
if (errors.size() > 0) { |
89 |
0
|
StringBuilder buf = new StringBuilder(); |
90 |
0
|
buf.append(errors.size()).append(" errors found while validating the data."); |
91 |
0
|
int cnt = 0; |
92 |
0
|
for (String msg : errors) { |
93 |
0
|
cnt++; |
94 |
0
|
buf.append("\n"); |
95 |
0
|
buf.append("*error*").append(cnt).append(":").append(msg); |
96 |
|
} |
97 |
|
|
98 |
0
|
fail(buf.toString()); |
99 |
|
} |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
4
-
|
|
105 |
0
|
@Test... |
106 |
|
public void testGetServiceMethods() { |
107 |
0
|
System.out.println("getServiceMethods"); |
108 |
0
|
ServiceContractModel model = getModel(); |
109 |
0
|
List<ServiceMethod> result = model.getServiceMethods(); |
110 |
0
|
System.out.println("Number of methods=" + result.size()); |
111 |
0
|
for (ServiceMethod method : result) { |
112 |
0
|
System.out.println(dump(method)); |
113 |
|
} |
114 |
0
|
if (result.size() < 1) { |
115 |
0
|
fail("too few: " + result.size()); |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4
-
|
|
122 |
0
|
@Test... |
123 |
|
public void testGetSourceNames() { |
124 |
0
|
System.out.println("getSourceNames"); |
125 |
0
|
ServiceContractModel model = getModel(); |
126 |
0
|
List<String> expResult = new ArrayList(); |
127 |
0
|
expResult.add(PESC_COLL_TRANS); |
128 |
0
|
List result = model.getSourceNames(); |
129 |
0
|
assertEquals(expResult, result); |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4
-
|
|
135 |
0
|
@Test... |
136 |
|
public void testGetServices() { |
137 |
0
|
System.out.println("getServices"); |
138 |
0
|
ServiceContractModel model = getModel(); |
139 |
0
|
List<Service> result = model.getServices(); |
140 |
0
|
assertEquals(1, result.size()); |
141 |
0
|
for (Service service : result) { |
142 |
0
|
System.out.println(service.getKey() + " " + service.getName() + " " |
143 |
|
+ service.getVersion() + " " + service.getStatus() |
144 |
|
+ " " + service.getComments() |
145 |
|
+ " " + service.getUrl()); |
146 |
|
} |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
4
-
|
|
152 |
0
|
@Test... |
153 |
|
public void testGetXmlTypes() { |
154 |
0
|
System.out.println("getXmlTypes"); |
155 |
0
|
ServiceContractModel model = getModel(); |
156 |
0
|
List<XmlType> result = model.getXmlTypes(); |
157 |
0
|
if (result.size() < 10) { |
158 |
0
|
fail("too few: " + result.size()); |
159 |
|
} |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
4
-
|
|
165 |
0
|
@Test... |
166 |
|
public void testGetMessageStructures() { |
167 |
0
|
System.out.println("getMessageStructures"); |
168 |
0
|
ServiceContractModel model = getModel(); |
169 |
0
|
List<MessageStructure> result = model.getMessageStructures(); |
170 |
0
|
if (result.size() < 10) { |
171 |
0
|
fail("too few: " + result.size()); |
172 |
|
} |
173 |
0
|
for (MessageStructure ms : result) { |
174 |
0
|
new MessageStructureDumper(ms, System.out).dump(); |
175 |
|
} |
176 |
|
} |
177 |
|
} |