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.ServiceMethod; |
19 |
|
import org.kuali.student.contract.model.ServiceMethodParameter; |
20 |
|
|
21 |
|
import java.util.ArrayList; |
22 |
|
import java.util.Collection; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
@author |
27 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 8 |
Complexity Density: 0.57 |
|
28 |
|
public class ServiceMethodParameterValidator implements ModelValidator { |
29 |
|
|
30 |
|
private ServiceMethodParameter parameter; |
31 |
|
private ServiceMethod method; |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
33 |
0
|
public ServiceMethodParameterValidator(ServiceMethodParameter parameter,... |
34 |
|
ServiceMethod method) { |
35 |
0
|
this.parameter = parameter; |
36 |
0
|
this.method = method; |
37 |
|
} |
38 |
|
private Collection errors; |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
40 |
0
|
@Override... |
41 |
|
public Collection<String> validate() { |
42 |
0
|
errors = new ArrayList(); |
43 |
0
|
basicValidation(); |
44 |
0
|
return errors; |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
47 |
0
|
private void basicValidation() {... |
48 |
0
|
if (parameter.getName().equals("")) { |
49 |
0
|
addError("Name is required"); |
50 |
|
} |
51 |
0
|
if (parameter.getDescription().equals("")) { |
52 |
0
|
addError("Description is required"); |
53 |
|
} |
54 |
0
|
if (parameter.getType().equals("")) { |
55 |
0
|
addError("Type is required"); |
56 |
|
} |
57 |
|
} |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
59 |
0
|
private void addError(String msg) {... |
60 |
0
|
String error = "Error in parameter: " + method.getService() + "." |
61 |
|
+ method.getName() + "(" + parameter.getName() |
62 |
|
+ "): " + msg; |
63 |
0
|
if (!errors.contains(error)) { |
64 |
0
|
errors.add(error); |
65 |
|
} |
66 |
|
} |
67 |
|
} |