1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.uiextension.test.ui; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Before; |
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.test.ui.po.ViewPage; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
36 |
|
public class UIExtensionTest extends AbstractTest |
37 |
|
{ |
38 |
|
private static final String HELLOWORLD_UIX_PAGE = "HelloWorld"; |
39 |
|
|
40 |
|
private static final String HELLOWIKIWORLD_UIX_PAGE = "HelloWikiWorld"; |
41 |
|
|
42 |
|
|
43 |
|
@Rule |
44 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
46 |
1 |
@Before... |
47 |
|
public void setUp() |
48 |
|
{ |
49 |
|
|
50 |
1 |
getUtil().deletePage(getTestClassName(), HELLOWORLD_UIX_PAGE); |
51 |
1 |
getUtil().deletePage(getTestClassName(), HELLOWIKIWORLD_UIX_PAGE); |
52 |
|
|
53 |
1 |
getUtil().gotoPage("Main", "WebHome"); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void testUIExtension() |
58 |
|
{ |
59 |
|
|
60 |
1 |
final ViewPage testPage = getUtil().createPage(getTestClassName(), HELLOWORLD_UIX_PAGE, "{{velocity}}\n" |
61 |
|
+ "\n" |
62 |
|
+ "{{html}}\n" |
63 |
|
+ "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))" |
64 |
|
+ "$services.rendering.render($uix.execute(), " |
65 |
|
+ "'xhtml/1.0')#end\n" |
66 |
|
+ "{{/html}}\n" |
67 |
|
+ "\n" |
68 |
|
+ "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))\n" |
69 |
|
+ "$uix.parameters\n" |
70 |
|
+ "#end\n" |
71 |
|
+ "{{/velocity}}\n", "Hello World"); |
72 |
1 |
Assert.assertEquals("HelloWorld\n" |
73 |
|
+ "{HelloWorldKey=HelloWorldValue}", testPage.getContent()); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
1 |
getUtil().addObject(getTestClassName(), HELLOWIKIWORLD_UIX_PAGE, "XWiki.UIExtensionClass", |
78 |
|
"name", "helloWikiWorld2", |
79 |
|
"extensionPointId", "hello", |
80 |
|
"content", "HelloWikiWorld2", |
81 |
|
"parameters", "HelloWorldKey=zz2_$xcontext.user"); |
82 |
1 |
getUtil().addObject(getTestClassName(), HELLOWIKIWORLD_UIX_PAGE, "XWiki.UIExtensionClass", |
83 |
|
"name", "helloWikiWorld1", |
84 |
|
"extensionPointId", "hello", |
85 |
|
"content", "HelloWikiWorld1", |
86 |
|
"parameters", "HelloWorldKey=zz1_$xcontext.user"); |
87 |
1 |
getUtil().gotoPage(getTestClassName(), HELLOWORLD_UIX_PAGE); |
88 |
1 |
Assert.assertEquals("HelloWorld\n" |
89 |
|
+ "HelloWikiWorld1\n" |
90 |
|
+ "HelloWikiWorld2\n" |
91 |
|
+ "{HelloWorldKey=HelloWorldValue}\n" |
92 |
|
+ "{HelloWorldKey=zz1_XWiki.superadmin}\n" |
93 |
|
+ "{HelloWorldKey=zz2_XWiki.superadmin}", testPage.getContent()); |
94 |
|
} |
95 |
|
} |