01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.service;
17:
18: import java.util.List;
19:
20: import org.kuali.core.bo.user.AuthenticationUserId;
21: import org.kuali.core.bo.user.KualiGroup;
22: import org.kuali.core.bo.user.UniversalUser;
23: import org.kuali.kfs.context.KualiTestBase;
24: import org.kuali.kfs.context.SpringContext;
25: import org.kuali.test.ConfigureContext;
26:
27: /**
28: * This class tests the KualiGroup service.
29: */
30: @ConfigureContext
31: public class KualiGroupServiceTest extends KualiTestBase {
32:
33: private static final String TEST_GROUP_NAME = "WorkflowAdmin";
34: private static final String TEST_GROUP_USER = "KHUNTLEY";
35:
36: private UniversalUser universalUser;
37:
38: @Override
39: protected void setUp() throws Exception {
40: super .setUp();
41: universalUser = SpringContext.getBean(
42: UniversalUserService.class).getUniversalUser(
43: new AuthenticationUserId(TEST_GROUP_USER));
44: }
45:
46: public void testGetByGroupName() throws Exception {
47: KualiGroup kualiGroup = SpringContext.getBean(
48: KualiGroupService.class)
49: .getByGroupName(TEST_GROUP_NAME);
50: assertTrue(kualiGroup.hasMember(universalUser));
51: }
52:
53: public void testGetUsersGroups() throws Exception {
54: List<KualiGroup> groups = SpringContext.getBean(
55: KualiGroupService.class).getUsersGroups(universalUser);
56: assertNotNull(groups);
57: assertTrue(!groups.isEmpty());
58:
59: for (KualiGroup group : groups) {
60: assertTrue(
61: "user not a memeber of group and should be. user="
62: + universalUser + "; group="
63: + group.getGroupName(), group
64: .hasMember(universalUser));
65: }
66: }
67:
68: }
|