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

File UserDirectoryTest.java

 

Code metrics

0
15
1
1
71
33
1
0.07
15
1
1

Classes

Class Line # Actions
UserDirectoryTest 38 15 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    package org.xwiki.user.directory.test.ui;
21   
22    import org.junit.Rule;
23    import org.junit.Test;
24    import org.xwiki.test.ui.AbstractTest;
25    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
26    import org.xwiki.test.ui.po.LiveTableElement;
27    import org.xwiki.user.directory.test.po.UserDirectoryPage;
28   
29    import static org.junit.Assert.assertEquals;
30    import static org.junit.Assert.assertTrue;
31   
32    /**
33    * Tests the User Directory feature.
34    *
35    * @version $Id: 556312ab7447274fd3129b77917e2734cba83869 $
36    * @since 5.1M1
37    */
 
38    public class UserDirectoryTest extends AbstractTest
39    {
40    @Rule
41    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
42   
 
43  1 toggle @Test
44    public void verifyUserIsListed()
45    {
46    // Delete possible existing user
47  1 getUtil().deletePage("XWiki", "test");
48   
49  1 UserDirectoryPage page = UserDirectoryPage.gotoPage();
50   
51    // Verify that the user directory is empty when there's no user in the wiki
52  1 LiveTableElement liveTableElement = page.getUserDirectoryLiveTable();
53  1 assertEquals(0, liveTableElement.getRowCount());
54   
55    // Add a user and verify it's visible in the livetable
56  1 getUtil().createUserAndLogin("test", "testtest", "first_name", "John", "last_name", "Doe");
57    // Go back to the user directory page since the user creation navigated to another page
58  1 page = UserDirectoryPage.gotoPage();
59  1 assertEquals(1, liveTableElement.getRowCount());
60  1 assertTrue(liveTableElement.hasRow("User ID", "test"));
61  1 assertTrue(liveTableElement.hasRow("First Name", "John"));
62  1 assertTrue(liveTableElement.hasRow("Last Name", "Doe"));
63   
64    // Log out to verify the livetable works in guest view too
65  1 getUtil().forceGuestUser();
66  1 assertEquals(1, liveTableElement.getRowCount());
67  1 assertTrue(liveTableElement.hasRow("User ID", "test"));
68  1 assertTrue(liveTableElement.hasRow("First Name", "John"));
69  1 assertTrue(liveTableElement.hasRow("Last Name", "Doe"));
70    }
71    }