| 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.SearchResult; |
| 19 |
|
import org.kuali.student.contract.model.SearchType; |
| 20 |
|
|
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Collection; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
@author |
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 12 |
Complexity Density: 0.55 |
|
| 28 |
|
public class SearchResultValidator implements ModelValidator { |
| 29 |
|
|
| 30 |
|
private SearchResult result; |
| 31 |
|
private SearchType searchType; |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 33 |
0
|
public SearchResultValidator(SearchResult result, SearchType searchType) {... |
| 34 |
0
|
this.result = result; |
| 35 |
0
|
this.searchType = searchType; |
| 36 |
|
} |
| 37 |
|
private Collection errors; |
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 39 |
0
|
@Override... |
| 40 |
|
public Collection<String> validate() { |
| 41 |
0
|
errors = new ArrayList(); |
| 42 |
0
|
basicValidation(); |
| 43 |
0
|
if (result.getResultColumns() == null) { |
| 44 |
0
|
addError("A result column list is required"); |
| 45 |
|
} |
| 46 |
0
|
if (result.getResultColumns().size() == 0) { |
| 47 |
0
|
addError("A result must have at least one column"); |
| 48 |
|
} |
| 49 |
0
|
return errors; |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 52 |
0
|
private void basicValidation() {... |
| 53 |
0
|
if (result.getKey().equals("")) { |
| 54 |
0
|
addError("result key is required"); |
| 55 |
|
} |
| 56 |
0
|
if (!result.getType().equals("Result")) { |
| 57 |
0
|
addError("'Type' column in the result must be 'Result'"); |
| 58 |
|
} |
| 59 |
0
|
if (result.getName().equals("")) { |
| 60 |
0
|
addError("Name is required"); |
| 61 |
|
} |
| 62 |
0
|
if (result.getDescription().equals("")) { |
| 63 |
0
|
addError("Description is required"); |
| 64 |
|
} |
| 65 |
0
|
if (!result.getDataType().equals("")) { |
| 66 |
0
|
addError("Data Type should be blank"); |
| 67 |
|
} |
| 68 |
|
} |
| 69 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 70 |
0
|
private void addError(String msg) {... |
| 71 |
0
|
String error = "Error in result entry: " + searchType.getKey() + "." + result.getKey() |
| 72 |
|
+ ": " + msg; |
| 73 |
0
|
if (!errors.contains(error)) { |
| 74 |
0
|
errors.add(error); |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
|
} |