Clover Coverage Report - KS Services 0.0.1-SNAPSHOT (Aggregated)
Coverage timestamp: Mon May 23 2011 04:06:57 EDT
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
93   345   65   3.32
74   287   0.7   28
28     2.32  
1    
 
  PermissionServiceMockImpl       Line # 41 93 0% 65 195 0% 0.0
 
No Tests
 
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.bo.role.dto.KimPermissionInfo;
19    import org.kuali.rice.kim.bo.role.dto.KimPermissionTemplateInfo;
20   
21    import java.util.*;
22    import org.kuali.rice.kim.bo.Role;
23    import org.kuali.rice.kim.bo.role.dto.DelegateMemberCompleteInfo;
24    import org.kuali.rice.kim.bo.role.dto.DelegateTypeInfo;
25    import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;
26    import org.kuali.rice.kim.bo.role.dto.PermissionAssigneeInfo;
27    import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo;
28    import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo;
29    import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityActionInfo;
30    import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityInfo;
31    import org.kuali.rice.kim.bo.types.dto.AttributeSet;
32    import org.kuali.rice.kim.service.PermissionService;
33    import org.kuali.rice.kim.service.PermissionUpdateService;
34    import org.kuali.rice.kim.service.RoleManagementService;
35    import org.kuali.rice.kim.service.RoleService;
36    import org.kuali.rice.kim.service.RoleUpdateService;
37   
38    /**
39    * @author nwright
40    */
 
41    public class PermissionServiceMockImpl implements PermissionService,
42    PermissionUpdateService
43    {
44   
45    private transient Map<String, KimPermissionTemplateInfo> permissionTemplateCache = new HashMap<String, KimPermissionTemplateInfo>();
46    private transient Map<String, KimPermissionInfo> permissionCache = new HashMap<String, KimPermissionInfo>();
47    private transient Map<String, KimRoleInfo> roleCache = new HashMap<String, KimRoleInfo>();
48    private transient Map<String, RoleMembershipInfo> roleMembershipCache = new HashMap<String, RoleMembershipInfo>();
49   
 
50  0 toggle @Override
51    public List<KimPermissionTemplateInfo> getAllTemplates() {
52  0 return new ArrayList(this.permissionTemplateCache.values());
53    }
54   
 
55  0 toggle @Override
56    public List<KimPermissionInfo> getAuthorizedPermissions(String principalId,
57    String namespaceCode,
58    String permissionName,
59    AttributeSet permissionDetails,
60    AttributeSet qualification) {
61  0 List<KimPermissionInfo> list = new ArrayList<KimPermissionInfo>();
62  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
63  0 if (namespaceCode.equals(permission.getNamespaceCode())) {
64  0 if (permissionName.equals(permission.getName())) {
65  0 if (matchesPermissionDetails(permission, permissionDetails)) {
66  0 if (matchesQualification(permission, qualification)) {
67  0 if (matchesPrincipalId(permission, principalId)) {
68  0 list.add(permission);
69    }
70    }
71    }
72    }
73    }
74    }
75  0 return list;
76    }
77   
 
78  0 toggle private boolean matchesPermissionDetails(KimPermissionInfo permission, AttributeSet permissionDetails) {
79    // TODO: implement this check
80  0 return true;
81    }
82   
 
83  0 toggle private boolean matchesQualification(KimPermissionInfo permission, AttributeSet qualification) {
84    // TODO: implement this check
85  0 return true;
86    }
87   
 
88  0 toggle private boolean matchesPrincipalId(KimPermissionInfo permission, String principalId) {
89    // TODO: implement this check
90  0 return true;
91    }
92   
 
93  0 toggle @Override
94    public List<KimPermissionInfo> getAuthorizedPermissionsByTemplateName(String principalId,
95    String namespaceCode,
96    String permissionTemplateName,
97    AttributeSet permissionDetails,
98    AttributeSet qualification) {
99  0 List<KimPermissionInfo> list = new ArrayList<KimPermissionInfo>();
100  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
101  0 if (permission.getTemplate() != null) {
102  0 if (namespaceCode.equals(permission.getTemplate().getNamespaceCode())) {
103  0 if (permissionTemplateName.equals(permission.getTemplate().getName())) {
104  0 if (matchesPermissionDetails(permission, permissionDetails)) {
105  0 if (matchesQualification(permission, qualification)) {
106  0 if (matchesPrincipalId(permission, principalId)) {
107  0 list.add(permission);
108    }
109    }
110    }
111    }
112    }
113    }
114    }
115  0 return list;
116    }
117   
 
118  0 toggle @Override
119    public KimPermissionInfo getPermission(String permissionId) {
120  0 return this.permissionCache.get(permissionId);
121    }
122   
 
123  0 toggle @Override
124    public List<PermissionAssigneeInfo> getPermissionAssignees(String namespaceCode,
125    String permissionName,
126    AttributeSet permissionDetails,
127    AttributeSet qualification) {
128  0 List<PermissionAssigneeInfo> list = new ArrayList<PermissionAssigneeInfo>();
129  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
130  0 if (namespaceCode.equals(permission.getNamespaceCode())) {
131  0 if (permissionName.equals(permission.getName())) {
132  0 if (matchesPermissionDetails(permission, permissionDetails)) {
133  0 if (matchesQualification(permission, qualification)) {
134  0 list.addAll(getPermissionAssignees(permission));
135    }
136    }
137    }
138    }
139    }
140  0 return list;
141    }
142   
 
143  0 toggle private List<PermissionAssigneeInfo> getPermissionAssignees(KimPermissionInfo permission) {
144  0 List<PermissionAssigneeInfo> list = new ArrayList<PermissionAssigneeInfo>();
145    // TODO: Implement this
146  0 return list;
147    }
148   
 
149  0 toggle @Override
150    public List<PermissionAssigneeInfo> getPermissionAssigneesForTemplateName(String namespaceCode,
151    String permissionTemplateName,
152    AttributeSet permissionDetails,
153    AttributeSet qualification) {
154  0 List<PermissionAssigneeInfo> list = new ArrayList<PermissionAssigneeInfo>();
155  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
156  0 if (permission.getTemplate() != null) {
157  0 if (namespaceCode.equals(permission.getTemplate().getNamespaceCode())) {
158  0 if (permissionTemplateName.equals(permission.getTemplate().getName())) {
159  0 if (matchesPermissionDetails(permission, permissionDetails)) {
160  0 if (matchesQualification(permission, qualification)) {
161  0 list.addAll(getPermissionAssignees(permission));
162    }
163    }
164    }
165    }
166    }
167    }
168  0 return list;
169    }
170   
 
171  0 toggle @Override
172    public String getPermissionDetailLabel(String permissionId, String kimTypeId,
173    String attributeName) {
174    // TODO: figure out what this is
175  0 throw new UnsupportedOperationException("Not supported yet.");
176    }
177   
 
178  0 toggle @Override
179    public KimPermissionTemplateInfo getPermissionTemplate(String permissionTemplateId) {
180  0 return this.permissionTemplateCache.get(permissionTemplateId);
181    }
182   
 
183  0 toggle @Override
184    public KimPermissionTemplateInfo getPermissionTemplateByName(String namespaceCode,
185    String permissionTemplateName) {
186  0 for (KimPermissionTemplateInfo template : this.permissionTemplateCache.values()) {
187  0 if (template.getNamespaceCode().equals(namespaceCode)) {
188  0 if (template.getName().equals(permissionTemplateName)) {
189  0 return template;
190    }
191    }
192    }
193  0 return null;
194    }
195   
 
196  0 toggle @Override
197    public List<KimPermissionInfo> getPermissionsByName(String namespaceCode,
198    String permissionName) {
199  0 List<KimPermissionInfo> list = new ArrayList<KimPermissionInfo>();
200  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
201  0 if (namespaceCode.equals(permission.getNamespaceCode())) {
202  0 if (permissionName.equals(permission.getName())) {
203  0 if (permission.isActive()) {
204  0 list.add(permission);
205    }
206    }
207    }
208    }
209  0 return list;
210    }
211   
 
212  0 toggle @Override
213    public List<KimPermissionInfo> getPermissionsByNameIncludingInactive(String namespaceCode,
214    String permissionName) {
215  0 List<KimPermissionInfo> list = new ArrayList<KimPermissionInfo>();
216  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
217  0 if (namespaceCode.equals(permission.getNamespaceCode())) {
218  0 if (permissionName.equals(permission.getName())) {
219  0 list.add(permission);
220    }
221    }
222    }
223  0 return list;
224    }
225   
 
226  0 toggle @Override
227    public List<KimPermissionInfo> getPermissionsByTemplateName(String namespaceCode,
228    String permissionTemplateName) {
229  0 List<KimPermissionInfo> list = new ArrayList<KimPermissionInfo>();
230  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
231  0 if (permission.getTemplate() != null) {
232  0 if (namespaceCode.equals(permission.getTemplate().getNamespaceCode())) {
233  0 if (permissionTemplateName.equals(permission.getTemplate().getName())) {
234  0 list.add(permission);
235    }
236    }
237    }
238    }
239  0 return list;
240    }
241   
 
242  0 toggle @Override
243    public List<String> getRoleIdsForPermission(String namespaceCode,
244    String permissionName,
245    AttributeSet permissionDetails) {
246  0 throw new UnsupportedOperationException("Not supported yet.");
247    }
248   
 
249  0 toggle @Override
250    public List<String> getRoleIdsForPermissionId(String permissionId) {
251  0 throw new UnsupportedOperationException("Not supported yet.");
252    }
253   
 
254  0 toggle @Override
255    public List<String> getRoleIdsForPermissions(List<KimPermissionInfo> permissions) {
256  0 throw new UnsupportedOperationException("Not supported yet.");
257    }
258   
 
259  0 toggle @Override
260    public boolean hasPermission(String principalId, String namespaceCode,
261    String permissionName,
262    AttributeSet permissionDetails) {
263  0 throw new UnsupportedOperationException("Not supported yet.");
264    }
265   
 
266  0 toggle @Override
267    public boolean hasPermissionByTemplateName(String principalId,
268    String namespaceCode,
269    String permissionTemplateName,
270    AttributeSet permissionDetails) {
271  0 throw new UnsupportedOperationException("Not supported yet.");
272    }
273   
 
274  0 toggle @Override
275    public boolean isAuthorized(String principalId, String namespaceCode,
276    String permissionName,
277    AttributeSet permissionDetails,
278    AttributeSet qualification) {
279  0 throw new UnsupportedOperationException("Not supported yet.");
280    }
281   
 
282  0 toggle @Override
283    public boolean isAuthorizedByTemplateName(String principalId,
284    String namespaceCode,
285    String permissionTemplateName,
286    AttributeSet permissionDetails,
287    AttributeSet qualification) {
288  0 throw new UnsupportedOperationException("Not supported yet.");
289    }
290   
 
291  0 toggle @Override
292    public boolean isPermissionDefined(String namespaceCode, String permissionName,
293    AttributeSet permissionDetails) {
294  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
295  0 if (namespaceCode.equals(permission.getNamespaceCode())) {
296  0 if (permissionName.equals(permission.getName())) {
297  0 if (matchesPermissionDetails(permission, permissionDetails)) {
298  0 return true;
299    }
300    }
301    }
302    }
303   
304  0 return false;
305    }
306   
 
307  0 toggle @Override
308    public boolean isPermissionDefinedForTemplateName(String namespaceCode,
309    String permissionTemplateName,
310    AttributeSet permissionDetails) {
311  0 for (KimPermissionInfo permission : this.permissionCache.values()) {
312  0 if (permission.getTemplate() != null) {
313  0 if (namespaceCode.equals(permission.getTemplate().getNamespaceCode())) {
314  0 if (permissionTemplateName.equals(permission.getTemplate().getName())) {
315  0 if (matchesPermissionDetails(permission, permissionDetails)) {
316  0 return true;
317    }
318    }
319    }
320    }
321    }
322  0 return false;
323    }
324   
 
325  0 toggle @Override
326    public List<KimPermissionInfo> lookupPermissions(Map<String, String> searchCriteria,
327    boolean unbounded) {
328  0 throw new UnsupportedOperationException("Not supported yet.");
329    }
330   
 
331  0 toggle @Override
332    public String getNextAvailablePermissionId() throws UnsupportedOperationException {
333  0 throw new UnsupportedOperationException("Not supported yet.");
334    }
335   
 
336  0 toggle @Override
337    public void savePermission(String permissionId, String permissionTemplateId,
338    String namespaceCode, String name,
339    String description, boolean active,
340    AttributeSet permissionDetails) {
341  0 throw new UnsupportedOperationException("Not supported yet.");
342    }
343   
344    }
345