001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/profile/tags/sakai_2-4-1/common-composite-component/src/test/org/sakaiproject/api/common/edu/person/SakaiPersonManagerTest.java $
003: * $Id: SakaiPersonManagerTest.java 9229 2006-05-10 16:51:18Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.api.common.edu.person;
021:
022: import java.util.Iterator;
023: import java.util.List;
024:
025: import org.sakaiproject.api.common.agent.AgentGroupManager;
026: import org.sakaiproject.api.common.type.Type;
027: import org.sakaiproject.api.common.uuid.UuidManager;
028: import org.sakaiproject.component.junit.spring.ApplicationContextBaseTest;
029:
030: public class SakaiPersonManagerTest extends ApplicationContextBaseTest {
031: private SakaiPersonManager sakaiPersonManager; // dep inj
032: private UuidManager uuidManager; //dep inj
033: private AgentGroupManager agentGroupManager; // dep inj
034:
035: public SakaiPersonManagerTest() {
036: super ();
037: init();
038: }
039:
040: public SakaiPersonManagerTest(String name) {
041: super (name);
042: init();
043: }
044:
045: private void init() {
046: sakaiPersonManager = (SakaiPersonManager) getApplicationContext()
047: .getBean(SakaiPersonManager.class.getName());
048: uuidManager = (UuidManager) getApplicationContext().getBean(
049: UuidManager.class.getName());
050: agentGroupManager = (AgentGroupManager) getApplicationContext()
051: .getBean(AgentGroupManager.class.getName());
052: }
053:
054: /**
055: * @see org.sakaiproject.component.junit.spring.ApplicationContextBaseTest#setUp()
056: */
057: protected void setUp() throws Exception {
058: super .setUp();
059: }
060:
061: /**
062: * @see org.sakaiproject.component.junit.spring.ApplicationContextBaseTest#tearDown()
063: */
064: protected void tearDown() throws Exception {
065: super .tearDown();
066: }
067:
068: public void testCreate() {
069: String agentUuid1 = uuidManager.createUuid();
070: SakaiPerson sp1 = sakaiPersonManager.create(agentUuid1,
071: sakaiPersonManager.getUserMutableType());
072: assertTrue(sp1 != null);
073: assertTrue(agentUuid1.equals(sp1.getAgentUuid()));
074: assertTrue(sakaiPersonManager.getUserMutableType().getUuid()
075: .equals(sp1.getTypeUuid()));
076: }
077:
078: public void testSave() {
079: String agentUuid2 = uuidManager.createUuid();
080: SakaiPerson sp2 = sakaiPersonManager.create(agentUuid2,
081: sakaiPersonManager.getUserMutableType());
082: assertTrue(sp2 != null);
083: assertTrue(agentUuid2.equals(sp2.getAgentUuid()));
084: assertTrue(sakaiPersonManager.getUserMutableType().getUuid()
085: .equals(sp2.getTypeUuid()));
086:
087: sp2.setAgentUuid(agentGroupManager.getAgent().getUuid());
088: String username = "username";
089: sp2.setUid(username);
090: sakaiPersonManager.save(sp2);
091:
092: List l1 = sakaiPersonManager.findSakaiPersonByUid(username);
093: assertTrue(l1 != null && !l1.isEmpty());
094: for (Iterator iter = l1.iterator(); iter.hasNext();) {
095: SakaiPerson sp = (SakaiPerson) iter.next();
096: assertTrue(sp.getUid().equals(username));
097: }
098: }
099:
100: public void testGetPrototype() {
101: SakaiPerson sp = sakaiPersonManager.getPrototype();
102: assertTrue(sp != null && sp.getUuid() == null);
103: }
104:
105: /*
106: * Class under test for List getSakaiPerson(String)
107: */
108: public void testGetSakaiPersonString() {
109: }
110:
111: /*
112: * Class under test for List findSakaiPerson(SakaiPerson)
113: */
114: public void testFindSakaiPersonSakaiPerson() {
115: }
116:
117: /*
118: * Class under test for SakaiPerson getSakaiPerson(Type)
119: */
120: public void testGetSakaiPersonType() {
121: }
122:
123: /*
124: * Class under test for SakaiPerson getSakaiPerson(String, Type)
125: */
126: public void testGetSakaiPersonStringType() {
127: }
128:
129: public void testGetUserMutableType() {
130: Type t = sakaiPersonManager.getUserMutableType();
131: assertTrue(t != null);
132: }
133:
134: public void testGetSystemMutableType() {
135: Type t = sakaiPersonManager.getSystemMutableType();
136: assertTrue(t != null);
137: }
138:
139: public void testDelete() {
140: }
141:
142: /*
143: * Class under test for List findSakaiPerson(String)
144: */
145: public void testFindSakaiPersonString() {
146: }
147:
148: }
|