1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.watchlist.test.ui; |
21 |
|
|
22 |
|
import org.apache.commons.lang.RandomStringUtils; |
23 |
|
import org.junit.Assert; |
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.test.ui.AbstractTest; |
27 |
|
import org.xwiki.test.ui.po.ViewPage; |
28 |
|
import org.xwiki.watchlist.test.po.WatchlistMacro; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 2 |
Complexity Density: 0.07 |
|
35 |
|
public class WatchlistMacroTest extends AbstractTest |
36 |
|
{ |
37 |
|
private WatchlistMacro watchlistMacro; |
38 |
|
private String testSpace; |
39 |
|
private String testPage; |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
41 |
1 |
@Before... |
42 |
|
public void setUp() { |
43 |
1 |
String userName = RandomStringUtils.randomAlphanumeric(5); |
44 |
1 |
getUtil().createUserAndLogin(userName, "password"); |
45 |
|
|
46 |
1 |
this.watchlistMacro = new WatchlistMacro(); |
47 |
1 |
this.testSpace = userName + "Test"; |
48 |
1 |
this.testPage = "TestWatchlist"; |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void testWatchAndRemoveEntries() { |
53 |
|
|
54 |
1 |
ViewPage testPageView = getUtil().createPage(this.testSpace, this.testPage, "{{watchlist /}}", "Watch list"); |
55 |
|
|
56 |
|
|
57 |
1 |
Assert.assertTrue("Newly created page is not watched", |
58 |
|
this.watchlistMacro.isWatched(this.testSpace, this.testPage)); |
59 |
1 |
Assert.assertFalse("Newly created space is watched", this.watchlistMacro.isWatched(this.testSpace)); |
60 |
1 |
Assert.assertFalse("Complete wiki is watched", this.watchlistMacro.isWikiWatched()); |
61 |
|
|
62 |
1 |
testPageView.watchSpace(); |
63 |
1 |
testPageView.watchWiki(); |
64 |
|
|
65 |
|
|
66 |
1 |
getUtil().gotoPage("Main", "WebHome"); |
67 |
1 |
testPageView = getUtil().gotoPage(this.testSpace, this.testPage); |
68 |
|
|
69 |
1 |
Assert.assertTrue("Newly created page is not watched", |
70 |
|
this.watchlistMacro.isWatched(this.testSpace, this.testPage)); |
71 |
1 |
Assert.assertTrue("Test space is not watched", this.watchlistMacro.isWatched(this.testSpace)); |
72 |
1 |
Assert.assertTrue("Complete wiki is not watched", this.watchlistMacro.isWikiWatched()); |
73 |
|
|
74 |
1 |
this.watchlistMacro.unWatch(null, null); |
75 |
1 |
this.watchlistMacro.unWatch(this.testSpace, this.testPage); |
76 |
|
|
77 |
|
|
78 |
1 |
getUtil().gotoPage("Main", "WebHome"); |
79 |
1 |
testPageView = getUtil().gotoPage(this.testSpace, this.testPage); |
80 |
|
|
81 |
1 |
Assert.assertFalse("Newly created page is still watched", |
82 |
|
this.watchlistMacro.isWatched(this.testSpace, this.testPage)); |
83 |
1 |
Assert.assertTrue("Test space is not watched", this.watchlistMacro.isWatched(this.testSpace)); |
84 |
1 |
Assert.assertFalse("Complete wiki is still watched", this.watchlistMacro.isWikiWatched()); |
85 |
|
|
86 |
1 |
this.watchlistMacro.unWatch(this.testSpace, null); |
87 |
|
|
88 |
|
|
89 |
1 |
getUtil().gotoPage("Main", "WebHome"); |
90 |
1 |
testPageView = getUtil().gotoPage(this.testSpace, this.testPage); |
91 |
1 |
Assert.assertFalse("Test space is still watched", this.watchlistMacro.isWatched(this.testSpace)); |
92 |
|
} |
93 |
|
} |