01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.services.persondir.support;
07:
08: import java.util.Collections;
09: import java.util.Map;
10: import java.util.Set;
11:
12: import org.jasig.portal.services.persondir.IPersonAttributeDao;
13:
14: /**
15: * A stub IPersonAttributeDao to be used for testing.
16: * Backed by a single Map which this implementation will always return.
17: *
18: * @author andrew.petro@yale.edu
19: * @version $Revision: 35519 $ $Date: 2005-04-06 12:10:32 -0700 (Wed, 06 Apr 2005) $
20: * @since uPortal 2.5
21: */
22: public class StubPersonAttributeDao implements IPersonAttributeDao {
23: private Map backingMap;
24:
25: public Set getPossibleUserAttributeNames() {
26: if (this .backingMap == null) {
27: return null;
28: }
29:
30: return Collections.unmodifiableSet(this .backingMap.keySet());
31: }
32:
33: public Map getUserAttributes(final Map seed) {
34: if (seed == null) {
35: throw new IllegalArgumentException(
36: "Illegal to invoke getUserAttributes(Map) with a null argument.");
37: }
38: return this .backingMap;
39: }
40:
41: public Map getUserAttributes(final String uid) {
42: if (uid == null) {
43: throw new IllegalArgumentException(
44: "Illegal to invoke getUserAttributes(String) with a null argument.");
45: }
46: return this .backingMap;
47: }
48:
49: /**
50: * Get the Map which this stub object will return for all legal invocations of
51: * attributesForUser()
52: *
53: * @return Returns the backingMap.
54: */
55: public Map getBackingMap() {
56: return this .backingMap;
57: }
58:
59: /**
60: * Set the Map which this stub object will return for all legal invocations of
61: * attributesForUser().
62: *
63: * @param backingMap The backingMap to set.
64: */
65: public void setBackingMap(final Map backingMap) {
66: this.backingMap = backingMap;
67: }
68: }
|