Coverage Report - org.kuali.student.process.poc.evaluator.DirectRuleCheckEvaluator
 
Classes in this File Line Coverage Branch Coverage Complexity
DirectRuleCheckEvaluator
0%
0/38
0%
0/10
3.143
 
 1  
 package org.kuali.student.process.poc.evaluator;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.kuali.rice.kim.api.identity.IdentityService;
 7  
 import org.kuali.rice.kim.api.identity.entity.Entity;
 8  
 import org.kuali.student.process.poc.context.DirectRuleCheckContext;
 9  
 import org.kuali.student.r2.common.dto.ContextInfo;
 10  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 11  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 12  
 import org.kuali.student.r2.common.util.constants.AtpServiceConstants;
 13  
 import org.kuali.student.r2.core.atp.dto.AtpInfo;
 14  
 import org.kuali.student.r2.core.atp.service.AtpService;
 15  
 import org.kuali.student.r2.core.process.dto.InstructionInfo;
 16  
 
 17  0
 public class DirectRuleCheckEvaluator implements CheckEvaluator<DirectRuleCheckContext> {
 18  
 
 19  
     public static final String AGENDA_IS_ALIVE = "kuali.agenda.is.alive";
 20  
     public static final String AGENDA_IS_NOT_SUMMER_TERM = "kuali.agenda.is.not.summer.term";
 21  
     private IdentityService identityService;
 22  
     private AtpService atpService;
 23  
 
 24  
     public IdentityService getIdentityService() {
 25  0
         return identityService;
 26  
     }
 27  
 
 28  
     public void setIdentityService(IdentityService identityService) {
 29  0
         this.identityService = identityService;
 30  0
     }
 31  
 
 32  
     public AtpService getAtpService() {
 33  0
         return atpService;
 34  
     }
 35  
 
 36  
     public void setAtpService(AtpService atpService) {
 37  0
         this.atpService = atpService;
 38  0
     }
 39  
 
 40  
     @Override
 41  
     public List<ValidationResultInfo> evaluate(DirectRuleCheckContext checkContext, ContextInfo context) throws OperationFailedException {
 42  0
         List<ValidationResultInfo> vrs = new ArrayList<ValidationResultInfo>();
 43  0
         ValidationResultInfo vr = null;
 44  
         // is alive check
 45  0
         if (checkContext.getCheck().getAgendaId().equals(AGENDA_IS_ALIVE)) {
 46  0
             Entity entity = identityService.getEntity(checkContext.getStudentId());
 47  0
             if (entity == null) {
 48  0
                 throw new OperationFailedException("studentId not found" + checkContext.getStudentId());
 49  
             }
 50  0
             if (entity.getBioDemographics().getDeceasedDate() == null) {
 51  0
                 vr = initInfo(checkContext.getInstruction());
 52  0
                 vrs.add(vr);
 53  0
                 return vrs;
 54  
             }
 55  0
             vr = initError(checkContext.getInstruction());
 56  0
             vrs.add(vr);
 57  0
             return vrs;
 58  
         }
 59  
         // is not summer term
 60  0
         if (checkContext.getCheck().getAgendaId().equals(AGENDA_IS_NOT_SUMMER_TERM)) {
 61  0
             AtpInfo atp = null;
 62  
             try {
 63  0
                 atp = atpService.getAtp(checkContext.getAtpKey(), context);
 64  0
             } catch (OperationFailedException ex) {
 65  0
                 throw ex;
 66  0
             } catch (Exception ex) {
 67  0
                 throw new OperationFailedException("unexpected", ex);
 68  0
             }
 69  
 
 70  
 
 71  0
             if (atp.getTypeKey().equals(AtpServiceConstants.ATP_SUMMER_TYPE_KEY)) {
 72  0
                 vr = initInfo(checkContext.getInstruction());
 73  0
                 vrs.add(vr);
 74  0
                 return vrs;
 75  
             }
 76  0
             vr = initError(checkContext.getInstruction());
 77  0
             vrs.add(vr);
 78  0
             return vrs;
 79  
         }
 80  0
         throw new OperationFailedException ("unknown/supported Agenda Id=" + checkContext.getCheck().getAgendaId());
 81  
     }
 82  
 
 83  
     private static ValidationResultInfo initError(InstructionInfo instruction) {
 84  0
         return MilestoneCheckEvaluator.initError(instruction);
 85  
     }
 86  
 
 87  
     private static ValidationResultInfo initInfo(InstructionInfo instruction) {
 88  0
         return MilestoneCheckEvaluator.initInfo(instruction);
 89  
     }
 90  
 }