Coverage Report - org.kuali.student.enrollment.class2.courseregistration.service.decorators.CourseRegistrationServiceValidationDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseRegistrationServiceValidationDecorator
0%
0/19
0%
0/10
2.143
 
 1  
 package org.kuali.student.enrollment.class2.courseregistration.service.decorators;
 2  
 
 3  
 import org.kuali.student.enrollment.courseregistration.dto.RegRequestInfo;
 4  
 import org.kuali.student.enrollment.courseregistration.dto.RegResponseInfo;
 5  
 import org.kuali.student.enrollment.courseregistration.service.CourseRegistrationServiceDecorator;
 6  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionInfo;
 7  
 import org.kuali.student.enrollment.lpr.service.LuiPersonRelationService;
 8  
 import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator;
 9  
 import org.kuali.student.r2.common.datadictionary.service.DataDictionaryService;
 10  
 import org.kuali.student.r2.common.dto.ContextInfo;
 11  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 12  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 13  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 14  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 15  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 16  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 17  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 18  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 19  
 import org.kuali.student.r2.common.infc.ValidationResult;
 20  
 import org.kuali.student.r2.common.util.constants.LuiPersonRelationServiceConstants;
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.List;
 24  
 
 25  0
 public class CourseRegistrationServiceValidationDecorator extends CourseRegistrationServiceDecorator {
 26  
 
 27  
     private DataDictionaryValidator validator;
 28  
     private DataDictionaryService dataDictionaryService;
 29  
 
 30  
     public void setLprService(LuiPersonRelationService lprService) {
 31  0
         this.lprService = lprService;
 32  0
     }
 33  
 
 34  
     private LuiPersonRelationService lprService;
 35  
 
 36  
     public DataDictionaryValidator getValidator() {
 37  0
         return validator;
 38  
     }
 39  
 
 40  
     public void setValidator(DataDictionaryValidator validator) {
 41  0
         this.validator = validator;
 42  0
     }
 43  
 
 44  
     public DataDictionaryService getDataDictionaryService() {
 45  0
         return dataDictionaryService;
 46  
     }
 47  
 
 48  
     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
 49  0
         this.dataDictionaryService = dataDictionaryService;
 50  0
     }
 51  
 
 52  
     @Override
 53  
     public RegRequestInfo createRegRequest(RegRequestInfo regRequestInfo, ContextInfo context)
 54  
             throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException,
 55  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 56  0
         if (regRequestInfo.getRequestorId() == null)
 57  0
             throw new DataValidationErrorException("Null field requestorId");
 58  0
         if (regRequestInfo.getRegRequestItems() == null)
 59  0
             throw new DataValidationErrorException("Not a valid request, missing request items");
 60  
 
 61  0
         return getNextDecorator().createRegRequest(regRequestInfo, context);
 62  
     }
 63  
     
 64  
     @Override
 65  
     public RegResponseInfo submitRegRequest(String regRequestId, ContextInfo context) throws DoesNotExistException,
 66  
     InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException,
 67  
     DataValidationErrorException, AlreadyExistsException {
 68  
 
 69  0
         LprTransactionInfo storedLprTransaction = lprService.getLprTransaction(regRequestId, context);
 70  0
         List<ValidationResultInfo> validationErrors = new ArrayList<ValidationResultInfo>();
 71  
 
 72  0
          if(storedLprTransaction.getStateKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_SUCCEEDED_STATE_KEY)||
 73  
                 storedLprTransaction.getStateKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_DISCARDED_STATE_KEY)||
 74  
                  storedLprTransaction.getStateKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_FAILED_STATE_KEY)){
 75  
 
 76  0
              throw new DataValidationErrorException("The state key validation failed", validationErrors);
 77  
          }
 78  0
         return getNextDecorator().submitRegRequest(regRequestId, context);
 79  
     }
 80  
 }