Coverage Report - org.kuali.student.process.poc.ProcessPocPopulationServiceMockImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessPocPopulationServiceMockImpl
0%
0/89
0%
0/36
2.885
 
 1  
 /*
 2  
  * To change this template, choose Tools | Templates
 3  
  * and open the template in the editor.
 4  
  */
 5  
 package org.kuali.student.process.poc;
 6  
 
 7  
 
 8  
 
 9  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 10  
 import org.kuali.student.r2.common.datadictionary.dto.DictionaryEntryInfo;
 11  
 import org.kuali.student.r2.common.dto.ContextInfo;
 12  
 import org.kuali.student.r2.common.dto.StatusInfo;
 13  
 
 14  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 15  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 16  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 17  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 18  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 19  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 20  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 21  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 22  
 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
 23  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 24  
 import org.kuali.student.r2.core.population.dto.PopulationInfo;
 25  
 import org.kuali.student.r2.core.population.dto.PopulationRuleInfo;
 26  
 
 27  
 import javax.jws.WebParam;
 28  
 import java.util.ArrayList;
 29  
 import java.util.HashMap;
 30  
 import java.util.HashSet;
 31  
 import java.util.List;
 32  
 import java.util.Map;
 33  
 import java.util.Set;
 34  
 import org.kuali.student.r2.common.util.constants.PopulationServiceConstants;
 35  
 import org.kuali.student.r2.core.population.service.PopulationService;
 36  
 
 37  
 public class ProcessPocPopulationServiceMockImpl implements PopulationService {
 38  
 
 39  
     private static Map<String, PopulationInfo> populations;
 40  
     private static Map<String, Set<String>> caches;
 41  
 
 42  0
     public ProcessPocPopulationServiceMockImpl() {
 43  0
         initialize();
 44  0
     }
 45  
 
 46  
     private void initialize() {
 47  
         try {
 48  0
             populations = new HashMap<String, PopulationInfo>();
 49  0
             caches = new HashMap<String, Set<String>>();
 50  
 
 51  0
             final String ALL_STUDENTS = PopulationServiceConstants.EVERYONE_POPULATION_KEY;
 52  0
             final String SUMMER_ONLY_STUDENTS = PopulationServiceConstants.SUMMER_ONLY_STUDENTS_POPULATION_KEY;
 53  
 
 54  0
             PopulationInfo allStudentsPopulation = new PopulationInfo();
 55  0
             allStudentsPopulation.setKey(ALL_STUDENTS);
 56  0
             createPopulation(allStudentsPopulation, new ContextInfo());
 57  
 
 58  0
             PopulationInfo summerOnlyStudentsPopulation = new PopulationInfo();
 59  0
             summerOnlyStudentsPopulation.setKey(SUMMER_ONLY_STUDENTS);
 60  0
             createPopulation(summerOnlyStudentsPopulation, new ContextInfo());
 61  
 
 62  0
             caches.get(SUMMER_ONLY_STUDENTS).add("2155");
 63  
 
 64  0
             caches.get(ALL_STUDENTS).addAll(caches.get(SUMMER_ONLY_STUDENTS));
 65  0
             caches.get(ALL_STUDENTS).add("2005");
 66  0
             caches.get(ALL_STUDENTS).add("2016");
 67  0
             caches.get(ALL_STUDENTS).add("2132");
 68  0
             caches.get(ALL_STUDENTS).add("2166");
 69  0
             caches.get(ALL_STUDENTS).add("2272");
 70  0
             caches.get(ALL_STUDENTS).add("2374");
 71  0
             caches.get(ALL_STUDENTS).add("2397");
 72  0
             caches.get(ALL_STUDENTS).add("2406");
 73  
 
 74  0
         } catch (Exception e) {
 75  0
             e.printStackTrace();
 76  0
         }
 77  0
     }
 78  
 
 79  
     @Override
 80  
     public Boolean isMember(@WebParam(name = "personId") String personId, @WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 81  0
         if (null == personId || 0 == personId.length()) {
 82  0
             throw new MissingParameterException("personId");
 83  
         }
 84  0
         if (null == populationKey || 0 == populationKey.length()) {
 85  0
             throw new MissingParameterException("populationKey");
 86  
         }
 87  
 
 88  0
         Set<String> cache = caches.get(populationKey);
 89  0
         if (null == cache) {
 90  0
             throw new DoesNotExistException("populationKey '" + populationKey + "' not found");
 91  
         }
 92  0
         return cache.contains(personId);
 93  
     }
 94  
 
 95  
     @Override
 96  
     public List<String> getMembers(@WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 97  0
         if (null == populationKey || 0 == populationKey.length()) {
 98  0
             throw new MissingParameterException("populationKey");
 99  
         }
 100  
 
 101  0
         Set<String> cache = caches.get(populationKey);
 102  0
         if (null == cache) {
 103  0
             throw new DoesNotExistException("populationKey '" + populationKey + "' not found");
 104  
         }
 105  0
         return new ArrayList<String>(cache);
 106  
     }
 107  
 
 108  
     @Override
 109  
     public PopulationInfo getPopulation(@WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 110  0
         if (null == populationKey || 0 == populationKey.length()) {
 111  0
             throw new MissingParameterException("populationKey");
 112  
         }
 113  
 
 114  0
         PopulationInfo population = populations.get(populationKey);
 115  0
         if (null == population) {
 116  0
             throw new DoesNotExistException("populationKey '" + populationKey + "' not found");
 117  
         }
 118  0
         return population;
 119  
     }
 120  
 
 121  
     @Override
 122  
     public List<PopulationInfo> getPopulationsByIds(@WebParam(name = "populationKeys") List<String> populationKeys, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 123  0
         if (0 == populationKeys.size()) {
 124  0
             throw new MissingParameterException("populationKeys");
 125  
         }
 126  
 
 127  0
         List<PopulationInfo> result = new ArrayList<PopulationInfo>();
 128  0
         for (String populationKey : populationKeys) {
 129  0
             PopulationInfo population = populations.get(populationKey);
 130  0
             if (null == population) {
 131  0
                 throw new DoesNotExistException("populationKey '" + populationKey + "' not found");
 132  
             }
 133  0
             result.add(population);
 134  0
         }
 135  0
         return result;
 136  
     }
 137  
 
 138  
     @Override
 139  
     public List<String> getPopulationKeysByType(@WebParam(name = "populationTypeId") String populationTypeId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 140  0
         throw new OperationFailedException("Method not implemented.");
 141  
     }
 142  
 
 143  
     @Override
 144  
     public List<PopulationInfo> getPopulationsForPopulationRule(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 145  0
         throw new OperationFailedException("Method not implemented.");
 146  
     }
 147  
 
 148  
     @Override
 149  
     public List<String> searchForPopulationKeys(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 150  0
         throw new OperationFailedException("Method not implemented.");
 151  
     }
 152  
 
 153  
     @Override
 154  
     public List<PopulationInfo> searchForPopulations(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 155  0
         throw new OperationFailedException("Method not implemented.");
 156  
     }
 157  
 
 158  
     @Override
 159  
     public List<ValidationResultInfo> validatePopulation(@WebParam(name = "validationTypeId") String validationTypeId, @WebParam(name = "populationInfo") PopulationInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 160  0
         throw new OperationFailedException("Method not implemented.");
 161  
     }
 162  
 
 163  
     @Override
 164  
     public PopulationInfo createPopulation(@WebParam(name = "populationInfo") PopulationInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 165  0
         PopulationInfo population = populations.get(populationInfo.getKey());
 166  0
         if (null != population) {
 167  0
             throw new AlreadyExistsException("populationKey '" + populationInfo.getKey() + "' already exists");
 168  
         }
 169  0
         populations.put(populationInfo.getKey(), populationInfo);
 170  0
         caches.put(populationInfo.getKey(), new HashSet<String>());
 171  0
         return populationInfo;
 172  
     }
 173  
 
 174  
     @Override
 175  
     public PopulationInfo updatePopulation(@WebParam(name = "populationKey") String populationKey, @WebParam(name = "populationInfo") PopulationInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 176  0
         throw new OperationFailedException("Method not implemented.");
 177  
     }
 178  
 
 179  
     @Override
 180  
     public StatusInfo deletePopulation(@WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 181  0
         if (null == populationKey || 0 == populationKey.length()) {
 182  0
             throw new MissingParameterException("populationKey");
 183  
         }
 184  
 
 185  0
         PopulationInfo population = populations.get(populationKey);
 186  0
         if (null == population) {
 187  0
             throw new DoesNotExistException("populationKey '" + populationKey + "' not found");
 188  
         }
 189  0
         populations.remove(populationKey);
 190  0
         caches.remove(populationKey);
 191  0
         return new StatusInfo();
 192  
     }
 193  
 
 194  
     @Override
 195  
     public PopulationRuleInfo getPopulationRule(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 196  0
         throw new OperationFailedException("Method not implemented.");
 197  
     }
 198  
 
 199  
     @Override
 200  
     public List<PopulationRuleInfo> getPopulationRulesByIds(@WebParam(name = "populationRuleIds") List<String> populationRuleIds, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 201  0
         throw new OperationFailedException("Method not implemented.");
 202  
     }
 203  
 
 204  
     @Override
 205  
     public List<String> getPopulationRuleIdsByType(@WebParam(name = "populationTypeKey") String populationTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 206  0
         throw new OperationFailedException("Method not implemented.");
 207  
     }
 208  
 
 209  
     @Override
 210  
     public PopulationRuleInfo getPopulationRuleForPopulation(@WebParam(name = "populationid") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 211  0
         throw new OperationFailedException("Method not implemented.");
 212  
     }
 213  
 
 214  
     @Override
 215  
     public List<String> searchForPopulationRuleIds(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 216  0
         throw new OperationFailedException("Method not implemented.");
 217  
     }
 218  
 
 219  
     @Override
 220  
     public List<PopulationRuleInfo> searchForPopulationRules(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 221  0
         throw new OperationFailedException("Method not implemented.");
 222  
     }
 223  
 
 224  
     @Override
 225  
     public List<ValidationResultInfo> validatePopulationRule(@WebParam(name = "validationTypeKey") String validationTypeKey, @WebParam(name = "populationRuleInfo") PopulationRuleInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 226  0
         throw new OperationFailedException("Method not implemented.");
 227  
     }
 228  
 
 229  
     @Override
 230  
     public PopulationRuleInfo createPopulationRule(@WebParam(name = "populationInfo") PopulationRuleInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
 231  0
         throw new OperationFailedException("Method not implemented.");
 232  
     }
 233  
 
 234  
     @Override
 235  
     public PopulationRuleInfo updatePopulationRule(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "populationInfo") PopulationRuleInfo populationInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
 236  0
         throw new OperationFailedException("Method not implemented.");
 237  
     }
 238  
 
 239  
     @Override
 240  
     public StatusInfo deletePopulationRule(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 241  0
         throw new OperationFailedException("Method not implemented.");
 242  
     }
 243  
 
 244  
     @Override
 245  
     public StatusInfo applyPopulationRuleToPopulation(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 246  0
         throw new OperationFailedException("Method not implemented.");
 247  
     }
 248  
 
 249  
     @Override
 250  
     public StatusInfo removePopulationRuleFromPopulation(@WebParam(name = "populationRuleId") String populationRuleId, @WebParam(name = "populationKey") String populationKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 251  0
         throw new OperationFailedException("Method not implemented.");
 252  
     }
 253  
 
 254  
    
 255  
 }