Coverage Report - org.kuali.student.enrollment.class2.acal.keyvalue.AcademicTermStateKeyValues
 
Classes in this File Line Coverage Branch Coverage Complexity
AcademicTermStateKeyValues
0%
0/20
0%
0/6
2.667
 
 1  
 package org.kuali.student.enrollment.class2.acal.keyvalue;
 2  
 
 3  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 4  
 import org.kuali.rice.core.api.util.ConcreteKeyValue;
 5  
 import org.kuali.rice.core.api.util.KeyValue;
 6  
 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
 7  
 import org.kuali.rice.krad.uif.view.ViewModel;
 8  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 9  
 import org.kuali.student.mock.utilities.TestHelper;
 10  
 import org.kuali.student.r2.common.constants.CommonServiceConstants;
 11  
 import org.kuali.student.r2.common.dto.ContextInfo;
 12  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 13  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 14  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 15  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 16  
 import org.kuali.student.r2.core.state.dto.StateInfo;
 17  
 
 18  
 import javax.xml.namespace.QName;
 19  
 import java.io.Serializable;
 20  
 import java.util.ArrayList;
 21  
 import java.util.Collections;
 22  
 import java.util.List;
 23  
 
 24  
 //Core slice class.
 25  
 @Deprecated
 26  0
 public class AcademicTermStateKeyValues extends UifKeyValuesFinderBase implements Serializable {
 27  
 
 28  
     private static final long serialVersionUID = 1L;
 29  
 
 30  
     private transient AcademicCalendarService acalService;
 31  
 
 32  
     private static List<StateInfo> termStates;
 33  
 
 34  
     @Override
 35  
     public List<KeyValue> getKeyValues(ViewModel model) {
 36  
 
 37  0
         List<KeyValue> keyValues = new ArrayList<KeyValue>();
 38  
 
 39  
         try {
 40  0
             List<StateInfo> states = getTermStates();
 41  0
             for (StateInfo state : states) {
 42  0
                 ConcreteKeyValue keyValue = new ConcreteKeyValue();
 43  0
                 keyValue.setKey(state.getKey());
 44  0
                 keyValue.setValue(state.getName());
 45  0
                 keyValues.add(keyValue);
 46  0
             }
 47  0
         } catch (Exception e) {
 48  0
             throw new RuntimeException(e);
 49  0
         }
 50  
 
 51  0
         return keyValues;
 52  
     }
 53  
 
 54  
     private List<StateInfo> getTermStates() throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException {
 55  0
         if(termStates == null) {
 56  
             //TODO:Build real context.
 57  0
             ContextInfo context = TestHelper.getContext1();
 58  
 
 59  0
             termStates = Collections.unmodifiableList(getAcalService().getTermStates(context));
 60  
         }
 61  
 
 62  0
         return termStates;
 63  
     }
 64  
 
 65  
     public AcademicCalendarService getAcalService() {
 66  0
         if(acalService == null) {
 67  0
             acalService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX + "acal", "AcademicCalendarService"));
 68  
         }
 69  0
         return this.acalService;
 70  
     }
 71  
 }