View Javadoc
1   /**
2    * Copyright 2005-2014 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.opensource.org/licenses/ecl2.php
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.rice.ken.services.impl;
17  
18  import org.junit.Ignore;
19  import org.junit.Test;
20  import org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl;
21  import org.kuali.rice.ken.test.KENTestCase;
22  import org.kuali.rice.ken.test.TestConstants;
23  import org.kuali.rice.kew.util.Utilities;
24  import org.kuali.rice.kim.api.KimConstants.KimGroupMemberTypes;
25  import org.kuali.rice.kim.api.group.Group;
26  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
27  
28  import static org.junit.Assert.*;
29  
30  /**
31   * This is a description of what this class does - chb don't forget to fill this in.
32   *
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   *
35   */
36  public class NotificationRecipientServiceKimImplTest extends KENTestCase {
37  
38      NotificationRecipientServiceKimImpl nrski = new NotificationRecipientServiceKimImpl();
39  
40      /**
41       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#getGroupMembers(java.lang.String)}.
42       */
43      @Test
44      public void testGetGroupMembersValid() {
45          Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
46                  Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
47                  TestConstants.VALID_KIM_GROUP_NAME_1));
48          assertTrue(nrski.getGroupMembers(group.getId()).length == TestConstants.KIM_GROUP_1_MEMBERS);
49      }
50  
51      /**
52       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#getUserDisplayName(java.lang.String)}.
53       */
54      @Test
55      @Ignore //  empty testGetUserDisplayName
56      public final void testGetUserDisplayName() {
57          //hoping gary will take care of this when he does KEW user conversion
58          fail("Not yet implemented"); // TODO
59      }
60  
61      /**
62       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isGroupRecipientValid(java.lang.String)}.
63       */
64      @Test
65      public final void testIsGroupRecipientValid() {
66          Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
67                  Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
68                  TestConstants.VALID_KIM_GROUP_NAME_1));
69          assertTrue(nrski.isGroupRecipientValid(group.getId()));
70      }
71  
72      /**
73       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isRecipientValid(java.lang.String, java.lang.String)}.
74       */
75      @Test
76      public final void testIsRecipientValid() {
77          assertTrue( nrski.isRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME, KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
78          assertFalse( nrski.isRecipientValid( "BoogalooShrimp44", KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
79  
80          Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
81                  Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
82                  TestConstants.VALID_KIM_GROUP_NAME_1));
83          assertTrue( nrski.isRecipientValid( group.getId(), KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
84          assertFalse( nrski.isRecipientValid( "FooSchnickens99", KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
85      }
86  
87      /**
88       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isUserRecipientValid(java.lang.String)}.
89       */
90      @Test
91      public final void testIsUserRecipientValid() {
92          assertTrue( nrski.isUserRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME ));
93      }
94  }