1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.contract.model.validation; |
17 |
|
|
18 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
19 |
|
import org.kuali.student.contract.model.ServiceMethod; |
20 |
|
import org.kuali.student.contract.model.XmlType; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.5 |
|
29 |
|
public class ServiceContractModelValidator implements ModelValidator { |
30 |
|
|
31 |
|
private ServiceContractModel model; |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
33 |
0
|
public ServiceContractModelValidator(ServiceContractModel model) {... |
34 |
0
|
this.model = model; |
35 |
|
} |
36 |
|
private Collection errors; |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
38 |
0
|
@Override... |
39 |
|
public Collection<String> validate() { |
40 |
0
|
errors = new ArrayList(); |
41 |
0
|
basicValidation(); |
42 |
0
|
this.validateServiceMethods(); |
43 |
0
|
validateXmlTypes(); |
44 |
0
|
return errors; |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
47 |
0
|
private void validateServiceMethods() {... |
48 |
0
|
for (ServiceMethod method : model.getServiceMethods()) { |
49 |
0
|
errors.addAll(new ServiceMethodValidator(method, model).validate()); |
50 |
|
} |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
53 |
0
|
private void validateXmlTypes() {... |
54 |
0
|
if (model.getXmlTypes().size() == 0) { |
55 |
0
|
addError("No xmlTypes found"); |
56 |
|
} |
57 |
0
|
for (XmlType xmlType : model.getXmlTypes()) { |
58 |
0
|
XmlTypesValidator validator = new XmlTypesValidator(xmlType, model); |
59 |
0
|
errors.addAll(validator.validate()); |
60 |
|
} |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
63 |
0
|
private void basicValidation() {... |
64 |
0
|
if (model.getServiceMethods().size() == 0) { |
65 |
0
|
addError("no service methods have been defined"); |
66 |
|
} |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
69 |
0
|
private void addError(String msg) {... |
70 |
0
|
String error = "Error in service methods: " + msg; |
71 |
0
|
if (!errors.contains(error)) { |
72 |
0
|
errors.add(error); |
73 |
|
} |
74 |
|
} |
75 |
|
} |