Coverage Report - org.kuali.student.contract.model.validation.ServiceMethodReturnValueValidator
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceMethodReturnValueValidator
0%
0/16
0%
0/6
1.75
 
 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.ServiceMethod;
 19  
 import org.kuali.student.contract.model.ServiceMethodReturnValue;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collection;
 23  
 
 24  
 /**
 25  
  * This validates a single resultinoary entry
 26  
  * @author nwright
 27  
  */
 28  
 public class ServiceMethodReturnValueValidator implements ModelValidator
 29  
 {
 30  
 
 31  
  private ServiceMethodReturnValue returnValue;
 32  
  private ServiceMethod serviceMethod;
 33  
 
 34  
  public ServiceMethodReturnValueValidator (ServiceMethodReturnValue returnValue,
 35  
                                            ServiceMethod serviceMethod)
 36  0
  {
 37  0
   this.returnValue = returnValue;
 38  0
   this.serviceMethod = serviceMethod;
 39  0
  }
 40  
 
 41  
  private Collection errors;
 42  
 
 43  
  @Override
 44  
  public Collection<String> validate ()
 45  
  {
 46  0
   errors = new ArrayList ();
 47  0
   basicValidation ();
 48  0
   return errors;
 49  
  }
 50  
 
 51  
  private void basicValidation ()
 52  
  {
 53  0
   if (returnValue.getType ().equals (""))
 54  
   {
 55  0
    addError ("return type is required");
 56  
   }
 57  0
   if (returnValue.getDescription ().equals (""))
 58  
   {
 59  0
    addError ("Description is required");
 60  
   }
 61  
  
 62  0
  }
 63  
 
 64  
  private void addError (String msg)
 65  
  {
 66  0
   String error = "Error in return value for method: " + serviceMethod.getService ()
 67  
    + "." + serviceMethod.getName () +  ": " + msg;
 68  0
   if ( ! errors.contains (error))
 69  
   {
 70  0
    errors.add (error);
 71  
   }
 72  0
  }
 73  
 
 74  
 }