View Javadoc

1   /**
2    * Copyright 2005-2013 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       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#getGroupMembers(java.lang.String)}.
41       */
42      @Test
43      public void testGetGroupMembersValid()
44      {
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
56      public final void testGetUserDisplayName()
57      {
58          //hoping gary will take care of this when he does KEW user conversion
59          fail("Not yet implemented"); // TODO
60      }
61  
62      /**
63       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isGroupRecipientValid(java.lang.String)}.
64       */
65      @Test
66      public final void testIsGroupRecipientValid()
67      {
68          Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
69                  Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
70                  TestConstants.VALID_KIM_GROUP_NAME_1));
71          assertTrue(nrski.isGroupRecipientValid(group.getId()));
72      }
73  
74      /**
75       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isRecipientValid(java.lang.String, java.lang.String)}.
76       */
77      @Test
78      public final void testIsRecipientValid()
79      {
80          assertTrue( nrski.isRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME, KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
81          assertFalse( nrski.isRecipientValid( "BoogalooShrimp44", KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
82  
83          Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
84                  Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
85                  TestConstants.VALID_KIM_GROUP_NAME_1));
86          assertTrue( nrski.isRecipientValid( group.getId(), KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
87          assertFalse( nrski.isRecipientValid( "FooSchnickens99", KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
88      }
89  
90      /**
91       * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isUserRecipientValid(java.lang.String)}.
92       */
93      @Test
94      public final void testIsUserRecipientValid()
95      {
96          assertTrue( nrski.isUserRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME ));
97      }
98  
99  }