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.kew.workgroup;
017    
018    import org.junit.Test;
019    import org.kuali.rice.kew.test.KEWTestCase;
020    import org.kuali.rice.kim.api.KimConstants;
021    import org.kuali.rice.kim.api.group.Group;
022    import org.kuali.rice.kim.api.group.GroupService;
023    import org.kuali.rice.kim.api.identity.IdentityService;
024    import org.kuali.rice.kim.api.services.KimApiServiceLocator;
025    import org.kuali.rice.test.BaselineTestCase;
026    
027    import java.util.List;
028    
029    import static org.junit.Assert.assertNotNull;
030    import static org.junit.Assert.assertTrue;
031    
032    /**
033     * This is a description of what this class does - jjhanso don't forget to fill this in.
034     *
035     * @author Kuali Rice Team (rice.collab@kuali.org)
036     *
037     */
038    @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
039    public class GroupXmlImportTest extends KEWTestCase {
040        /**
041         *
042         * Verify that a workgroup with a bad user in the xml is not going to be put in the db.
043         *
044         * @throws Exception
045         */
046    
047        @Test public void testGroupImportXml() throws Exception {
048            loadXmlFile("GroupXmlImportTest.xml");
049    
050            IdentityService identityService = KimApiServiceLocator.getIdentityService();
051            GroupService groupService = KimApiServiceLocator.getGroupService();
052            //verify that the group was ingested
053            Group group = groupService.getGroupByNamespaceCodeAndName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE,
054                    "TestUserGroup");
055    
056            assertNotNull(group);
057            List<String> members = groupService.getMemberPrincipalIds(group.getId());
058            List<String> groups = groupService.getMemberGroupIds(group.getId());
059            assertTrue(groupService.isMemberOfGroup(identityService.getPrincipalByPrincipalName("ewestfal").getPrincipalId(), group.getId()));
060            assertTrue(groupService.isMemberOfGroup(identityService.getPrincipalByPrincipalName("rkirkend").getPrincipalId(), group.getId()));
061            assertTrue(groupService.isMemberOfGroup("2015", group.getId()));
062            assertTrue(KimApiServiceLocator.getGroupService().isGroupMemberOfGroup(groupService.getGroupByNamespaceCodeAndName(
063                    KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup").getId(), group.getId()));
064        }
065    }