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