Coverage Report - org.kuali.student.kim.permission.mock.KimTypeInfoServiceMockImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KimTypeInfoServiceMockImpl
0%
0/20
0%
0/6
2
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may        obtain a copy of the License at
 7  
  *
 8  
  *         http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.student.kim.permission.mock;
 17  
 
 18  
 import org.kuali.rice.kim.api.type.KimType;
 19  
 import org.kuali.rice.kim.api.type.KimTypeInfoService;
 20  
 import org.kuali.rice.kim.framework.role.RoleTypeService;
 21  
 import org.kuali.rice.kns.kim.role.PrincipalDerivedRoleTypeServiceImpl;
 22  
 
 23  
 import java.util.Collection;
 24  
 import java.util.HashMap;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * Mock of the service to get kim type infos
 29  
  * 
 30  
  * @author nwright
 31  
  */
 32  0
 public class KimTypeInfoServiceMockImpl implements KimTypeInfoService {
 33  
 
 34  0
     private Map<String, KimType> kimTypeInfoCache = new HashMap<String, KimType>();
 35  0
     private Map<String, RoleTypeService> kimRoleTypeServiceCache = new HashMap <String, RoleTypeService> ();
 36  
     {
 37  0
         KimType.Builder info = KimType.Builder.create();
 38  0
         info.setId("2");
 39  0
         info.setServiceName(PrincipalDerivedRoleTypeServiceImpl.class.getName());
 40  0
         info.setName(PrincipalDerivedRoleTypeServiceImpl.class.getSimpleName());
 41  0
         info.setNamespaceCode(KimPermissionConstants.KR_IDM_NAMESPACE);
 42  0
         KimType data = info.build();
 43  0
         this.kimTypeInfoCache.put(info.getId(), data);
 44  0
         this.kimRoleTypeServiceCache.put (data.getServiceName(), new PrincipalDerivedRoleTypeServiceImpl ());
 45  0
     }
 46  
     @Override
 47  
     public Collection<KimType> findAllKimTypes() {
 48  0
         return this.kimTypeInfoCache.values();
 49  
     }
 50  
 
 51  
     @Override
 52  
     public KimType getKimType(String kimTypeId) {
 53  0
         return this.kimTypeInfoCache.get(kimTypeId);
 54  
     }
 55  
 
 56  
     @Override
 57  
     public KimType findKimTypeByNameAndNamespace(String namespaceCode, String typeName) {
 58  0
         for (KimType info : this.kimTypeInfoCache.values()) {
 59  0
             if (info.getNamespaceCode().equals(namespaceCode)) {
 60  0
                 if (info.getName().equals(typeName)) {
 61  0
                     return info;
 62  
                 }
 63  
             }
 64  
         }
 65  0
         return null;
 66  
     }
 67  
 
 68  
     // no usages no longer remotable from rice
 69  
     public RoleTypeService getRoleTypeService(KimType typeInfo) {
 70  0
         return null;
 71  
 
 72  
 //        String serviceName = typeInfo.getServiceName();
 73  
 //        if (serviceName == null) {
 74  
 //            return null;
 75  
 //        }
 76  
 //
 77  
 //        try {
 78  
 //            KimTypeService service = this.kimRoleTypeServiceCache.get(serviceName);
 79  
 //            if (service != null && service instanceof RoleTypeService) {
 80  
 //                return (RoleTypeService) service;
 81  
 //            } else {
 82  
 ////                return (KimRoleTypeService) KIMServiceLocatorWeb.getService("kimNoMembersRoleTypeService");
 83  
 ////                return new KimDerivedRoleTypeServiceBase ();
 84  
 //                return null; // remove once above is fixed
 85  
 //            }
 86  
 //        } catch (Exception ex) {
 87  
 ////            LOG.error("Unable to find role type service with name: " + serviceName);
 88  
 ////            LOG.error(ex.getClass().getName() + " : " + ex.getMessage());
 89  
 ////            return (KimRoleTypeService) KIMServiceLocatorWeb.getService("kimNoMembersRoleTypeService");
 90  
 ////            return new KimDerivedRoleTypeServiceBase ();
 91  
 //            return null; // remove once above is fixed
 92  
 //        }
 93  
     }
 94  
 }