View Javadoc

1   /*
2    * Copyright 2006-2011 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.kew.workgroup;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kew.test.KEWTestCase;
20  import org.kuali.rice.kim.api.group.Group;
21  import org.kuali.rice.kim.api.group.GroupService;
22  import org.kuali.rice.kim.api.identity.IdentityService;
23  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24  import org.kuali.rice.kim.util.KimConstants;
25  import org.kuali.rice.test.BaselineTestCase;
26  
27  import java.util.List;
28  
29  import static org.junit.Assert.assertNotNull;
30  import static org.junit.Assert.assertTrue;
31  
32  /**
33   * This is a description of what this class does - jjhanso don't forget to fill this in.
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   *
37   */
38  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
39  public class GroupXmlImportTest extends KEWTestCase {
40      /**
41       *
42       * Verify that a workgroup with a bad user in the xml is not going to be put in the db.
43       *
44       * @throws Exception
45       */
46  
47      @Test public void testGroupImportXml() throws Exception {
48      	loadXmlFile("GroupXmlImportTest.xml");
49  
50          IdentityService identityService = KimApiServiceLocator.getIdentityService();
51          GroupService groupService = KimApiServiceLocator.getGroupService();
52          //verify that the group was ingested
53          Group group = groupService.getGroupByName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestUserGroup");
54  
55          assertNotNull(group);
56          List<String> members = groupService.getMemberPrincipalIds(group.getId());
57          List<String> groups = groupService.getMemberGroupIds(group.getId());
58          assertTrue(groupService.isMemberOfGroup(identityService.getPrincipalByPrincipalName("ewestfal").getPrincipalId(), group.getId()));
59          assertTrue(groupService.isMemberOfGroup(identityService.getPrincipalByPrincipalName("rkirkend").getPrincipalId(), group.getId()));
60          assertTrue(groupService.isMemberOfGroup("2015", group.getId()));
61          assertTrue(KimApiServiceLocator.getGroupService().isGroupMemberOfGroup(groupService.getGroupByName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup").getId(), group.getId()));
62      }
63  }