1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.administration.test.ui

File GroupTest.java

 

Code metrics

0
16
1
1
77
39
1
0.06
16
1
1

Classes

Class Line # Actions
GroupTest 33 16 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20   
21    package org.xwiki.administration.test.ui;
22   
23    import static org.junit.Assert.assertTrue;
24   
25    import org.junit.Rule;
26    import org.junit.Test;
27    import org.xwiki.administration.test.po.GroupEditPage;
28    import org.xwiki.administration.test.po.GroupsPage;
29    import org.xwiki.model.reference.DocumentReference;
30    import org.xwiki.test.ui.AbstractTest;
31    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
32   
 
33    public class GroupTest extends AbstractTest
34    {
35    private static final String TESTER = "tester";
36   
37    private static final String SUB_GROUP = "subGroup";
38   
39    private static final String BIG_GROUP = "bigGroup";
40   
41    @Rule
42    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
43   
 
44  1 toggle @Test
45    public void addUserAndSubgroupToGroup() throws Exception
46    {
47    // Clean-up
48  1 getUtil().rest().deletePage("XWiki", BIG_GROUP);
49  1 getUtil().rest().deletePage("XWiki", SUB_GROUP);
50  1 getUtil().rest().deletePage("XWiki", TESTER);
51   
52    // Create the groups & the user
53  1 getUtil().createUser(TESTER, TESTER, "", "first_name", "", "last_name", "");
54  1 GroupsPage groupsPage = GroupsPage.gotoPage();
55  1 groupsPage.addNewGroup(SUB_GROUP);
56  1 groupsPage.addNewGroup(BIG_GROUP);
57   
58    // Test that the 2 groups have been successfully added
59  1 assertTrue("bigGroup doesn't exist!", groupsPage.getGroupsTable().hasRow("Group Name", BIG_GROUP));
60  1 assertTrue("subGroup doesn't exist!", groupsPage.getGroupsTable().hasRow("Group Name", SUB_GROUP));
61   
62    // Add SUB_GROUP & TESTER as members of BIG_GROUP
63  1 GroupEditPage bigGroupPage = GroupEditPage.gotoPage(new DocumentReference("xwiki", "XWiki", BIG_GROUP));
64  1 bigGroupPage.addMemberToGroup(SUB_GROUP, false);
65  1 bigGroupPage.addMemberToGroup(TESTER, true);
66   
67    // Test that SUB_GROUP is a member of BIG_GROUP
68  1 bigGroupPage.filterMembers(SUB_GROUP);
69  1 assertTrue("subGroup is not part of bigGroup!",
70    bigGroupPage.getMembersTable().hasRow("Member", String.format("%s (XWiki.%s)", SUB_GROUP, SUB_GROUP)));
71   
72    // Test that TESTER is a member of BIG_GROUP
73  1 bigGroupPage.filterMembers(TESTER);
74  1 assertTrue("tester is not part of bigGroup!",
75    bigGroupPage.getMembersTable().hasRow("Member", String.format("%s (XWiki.%s)", TESTER, TESTER)));
76    }
77    }