001    /**
002     * Copyright 2005-2011 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.ken.services.impl;
017    
018    import org.junit.Ignore;
019    import org.junit.Test;
020    import org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl;
021    import org.kuali.rice.ken.test.KENTestCase;
022    import org.kuali.rice.ken.test.TestConstants;
023    import org.kuali.rice.kew.util.Utilities;
024    import org.kuali.rice.kim.api.KimConstants.KimGroupMemberTypes;
025    import org.kuali.rice.kim.api.group.Group;
026    import org.kuali.rice.kim.api.services.KimApiServiceLocator;
027    
028    import static org.junit.Assert.*;
029    
030    /**
031     * This is a description of what this class does - chb don't forget to fill this in.
032     *
033     * @author Kuali Rice Team (rice.collab@kuali.org)
034     *
035     */
036    public class NotificationRecipientServiceKimImplTest extends KENTestCase
037    {
038        NotificationRecipientServiceKimImpl nrski = new NotificationRecipientServiceKimImpl();
039        /**
040         * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#getGroupMembers(java.lang.String)}.
041         */
042        @Test
043        public void testGetGroupMembersValid()
044        {
045            Group group = KimApiServiceLocator.getGroupService().getGroupByNameAndNamespaceCode(
046                    Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
047                    TestConstants.VALID_KIM_GROUP_NAME_1));
048            assertTrue(nrski.getGroupMembers(group.getId()).length == TestConstants.KIM_GROUP_1_MEMBERS);
049        }
050    
051        /**
052         * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#getUserDisplayName(java.lang.String)}.
053         */
054        @Test
055        @Ignore
056        public final void testGetUserDisplayName()
057        {
058            //hoping gary will take care of this when he does KEW user conversion
059            fail("Not yet implemented"); // TODO
060        }
061    
062        /**
063         * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isGroupRecipientValid(java.lang.String)}.
064         */
065        @Test
066        public final void testIsGroupRecipientValid()
067        {
068            Group group = KimApiServiceLocator.getGroupService().getGroupByNameAndNamespaceCode(
069                    Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
070                    TestConstants.VALID_KIM_GROUP_NAME_1));
071            assertTrue(nrski.isGroupRecipientValid(group.getId()));
072        }
073    
074        /**
075         * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isRecipientValid(java.lang.String, java.lang.String)}.
076         */
077        @Test
078        public final void testIsRecipientValid()
079        {
080            assertTrue( nrski.isRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME, KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
081            assertFalse( nrski.isRecipientValid( "BoogalooShrimp44", KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode()));
082    
083            Group group = KimApiServiceLocator.getGroupService().getGroupByNameAndNamespaceCode(
084                    Utilities.parseGroupNamespaceCode(TestConstants.VALID_KIM_GROUP_NAME_1), Utilities.parseGroupName(
085                    TestConstants.VALID_KIM_GROUP_NAME_1));
086            assertTrue( nrski.isRecipientValid( group.getId(), KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
087            assertFalse( nrski.isRecipientValid( "FooSchnickens99", KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode()));
088        }
089    
090        /**
091         * Test method for {@link org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl#isUserRecipientValid(java.lang.String)}.
092         */
093        @Test
094        public final void testIsUserRecipientValid()
095        {
096            assertTrue( nrski.isUserRecipientValid( TestConstants.VALID_KIM_PRINCIPAL_NAME ));
097        }
098    
099    }