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

File WatchUsersTest.java

 

Code metrics

0
22
1
1
83
42
1
0.05
22
1
1

Classes

Class Line # Actions
WatchUsersTest 40 22 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.watchlist.test.ui;
21   
22    import java.util.List;
23   
24    import org.junit.Rule;
25    import org.junit.Test;
26    import org.xwiki.test.ui.AbstractTest;
27    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
28    import org.xwiki.user.test.po.NetworkUserProfilePage;
29    import org.xwiki.user.test.po.ProfileUserProfilePage;
30   
31    import static org.junit.Assert.assertEquals;
32    import static org.junit.Assert.assertFalse;
33    import static org.junit.Assert.assertTrue;
34   
35    /**
36    * Tests the ability to watch users.
37    *
38    * @version $Id: 603c9aa8d2b9ae136ec6d43a9e77465f42b7409c $
39    */
 
40    public class WatchUsersTest extends AbstractTest
41    {
42    @Rule
43    public SuperAdminAuthenticationRule superAdminAuthenticationRule = new SuperAdminAuthenticationRule(getUtil());
44   
 
45  1 toggle @Test
46    public void testFollowUser() throws Exception
47    {
48    // Create 2 test users and log in with Bob, the creepy guy :).
49  1 String alice = "Alice";
50  1 getUtil().deletePage("XWiki", alice);
51  1 getUtil().createUser(alice, "password", null);
52   
53  1 String bob = "Bob";
54  1 getUtil().deletePage("XWiki", bob);
55  1 getUtil().createUserAndLogin(bob, "password");
56   
57    // Check that Bob does not follow anyone at the start.
58  1 NetworkUserProfilePage networkPage = NetworkUserProfilePage.gotoPage(bob);
59  1 List<String> followedUsers = networkPage.getFollowedUsers();
60  1 assertEquals("The list of followed users should be empty in the start", 0, followedUsers.size());
61   
62    // Go to Alice's profile, check that she is not followed then start following her.
63  1 ProfileUserProfilePage profilePage = ProfileUserProfilePage.gotoPage(alice);
64  1 assertFalse("Another users should not be followed by default", profilePage.isFollowed());
65  1 profilePage = profilePage.toggleFollowButton();
66  1 assertTrue("After following, the UI should show the unfollow option", profilePage.isFollowed());
67   
68    // Go to Bob's Network profile tab and check that Alice is followed.
69  1 networkPage = NetworkUserProfilePage.gotoPage(bob);
70  1 followedUsers = networkPage.getFollowedUsers();
71  1 assertEquals("There should be 1 user in the list of followed users", 1, followedUsers.size());
72  1 assertTrue("The user Alice should be in the list of followed users", followedUsers.contains(alice));
73   
74    // Unfollow Alice.
75  1 networkPage.unfollowUser(alice);
76  1 followedUsers = networkPage.getFollowedUsers();
77  1 assertEquals("There should be no more users in the list of followed users", 0, followedUsers.size());
78   
79    // Cleanup
80  1 getUtil().deletePage("XWiki", alice);
81  1 getUtil().deletePage("XWiki", bob);
82    }
83    }