Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
18   75   9   3
6   46   0.5   6
6     1.5  
1    
 
  ServiceContractModelValidator       Line # 29 18 0% 9 30 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
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    * This validates a single serviceMethodinoary entry
27    * @author nwright
28    */
 
29    public class ServiceContractModelValidator implements ModelValidator {
30   
31    private ServiceContractModel model;
32   
 
33  0 toggle public ServiceContractModelValidator(ServiceContractModel model) {
34  0 this.model = model;
35    }
36    private Collection errors;
37   
 
38  0 toggle @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   
 
47  0 toggle private void validateServiceMethods() {
48  0 for (ServiceMethod method : model.getServiceMethods()) {
49  0 errors.addAll(new ServiceMethodValidator(method, model).validate());
50    }
51    }
52   
 
53  0 toggle 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   
 
63  0 toggle private void basicValidation() {
64  0 if (model.getServiceMethods().size() == 0) {
65  0 addError("no service methods have been defined");
66    }
67    }
68   
 
69  0 toggle 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    }