1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.templating; |
35 |
|
|
36 |
|
import info.magnolia.cms.core.Content; |
37 |
|
import info.magnolia.test.MgnlTestCase; |
38 |
|
import info.magnolia.test.mock.MockUtil; |
39 |
|
|
40 |
|
import javax.jcr.RepositoryException; |
41 |
|
import java.io.IOException; |
42 |
|
|
43 |
|
|
44 |
|
@author |
45 |
|
@version |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (38) |
Complexity: 4 |
Complexity Density: 0.12 |
|
47 |
|
public class ParagraphManagerTest extends MgnlTestCase { |
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
48 |
1
|
public void testJspIsDefaultTypeIfNotSpecified() throws IOException, RepositoryException {... |
49 |
1
|
final Content paraNode = MockUtil.createHierarchyManager(PARA_NOTYPE).getContent("/modules/test/paragraph/foo"); |
50 |
1
|
final ParagraphManager pm = new ParagraphManager(); |
51 |
1
|
pm.addParagraphToCache(paraNode); |
52 |
1
|
final Paragraph p = pm.getParagraphDefinition("foo"); |
53 |
1
|
assertEquals("jsp", p.getType()); |
54 |
1
|
assertEquals("foo", p.getName()); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
73 |
1
|
public void testShouldUseNodeNameIfNoNameProperty() throws IOException, RepositoryException {... |
74 |
1
|
final Content paraNode = MockUtil.createHierarchyManager(PARA_NONAME).getContent("/modules/test/paragraph/noname"); |
75 |
1
|
final ParagraphManager pm = new ParagraphManager(); |
76 |
1
|
pm.addParagraphToCache(paraNode); |
77 |
1
|
final Paragraph p = pm.getParagraphDefinition("noname"); |
78 |
1
|
assertEquals("noname", p.getName()); |
79 |
1
|
assertEquals("jsp", p.getType()); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1
PASS
|
|
82 |
1
|
public void testNamePropertyShouldPrevailOverNodeName() throws IOException, RepositoryException {... |
83 |
1
|
final Content n = MockUtil.createHierarchyManager(PARA_TEST).getContent("/modules/test/paragraph"); |
84 |
1
|
final ParagraphManager pm = new ParagraphManager(); |
85 |
1
|
pm.onRegister(n); |
86 |
1
|
Paragraph baz = pm.getParagraphDefinition("baz"); |
87 |
1
|
assertEquals("baz", baz.getName()); |
88 |
1
|
assertEquals(null, pm.getParagraphDefinition("bar")); |
89 |
1
|
Paragraph foo = pm.getParagraphDefinition("foo"); |
90 |
1
|
assertEquals("foo", foo.getName()); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
93 |
1
|
public void testDialogNameShouldBeEqualsToParagraphNameIfNotSpecified() throws IOException, RepositoryException {... |
94 |
1
|
final Content n = MockUtil.createHierarchyManager(PARA_TEST).getContent("/modules/test/paragraph"); |
95 |
1
|
final Content c2 = MockUtil.createHierarchyManager(PARA_NONAME).getContent("/modules/test/paragraph"); |
96 |
1
|
final ParagraphManager pm = new ParagraphManager(); |
97 |
1
|
pm.onRegister(n); |
98 |
1
|
pm.onRegister(c2); |
99 |
|
|
100 |
1
|
final Paragraph baz = pm.getParagraphDefinition("foo"); |
101 |
1
|
assertEquals("foo", baz.getName()); |
102 |
1
|
assertEquals("fooDialog", baz.getDialog()); |
103 |
|
|
104 |
1
|
final Paragraph bar = pm.getParagraphDefinition("baz"); |
105 |
1
|
assertEquals("baz", bar.getName()); |
106 |
1
|
assertEquals("baz", bar.getDialog()); |
107 |
|
|
108 |
1
|
final Paragraph noname = pm.getParagraphDefinition("noname"); |
109 |
1
|
assertEquals("noname", noname.getName()); |
110 |
1
|
assertEquals("noname", noname.getDialog()); |
111 |
|
} |
112 |
|
|
113 |
|
private static final String PARA_NOTYPE = "" + |
114 |
|
"modules.test.paragraph.foo.@type=mgnl:contentNode\n" + |
115 |
|
"modules.test.paragraph.foo.name=foo"; |
116 |
|
|
117 |
|
private static final String PARA_NONAME = "" + |
118 |
|
"modules.test.paragraph.noname.@type=mgnl:contentNode"; |
119 |
|
|
120 |
|
private static final String PARA_TEST = "" + |
121 |
|
|
122 |
|
"modules.test.paragraph.foo.@type=mgnl:contentNode\n" + |
123 |
|
"modules.test.paragraph.foo.name=foo\n" + |
124 |
|
"modules.test.paragraph.foo.type=jsp\n" + |
125 |
|
"modules.test.paragraph.foo.dialog=fooDialog\n" + |
126 |
|
"modules.test.paragraph.bar.@type=mgnl:contentNode\n" + |
127 |
|
"modules.test.paragraph.bar.name=baz\n" + |
128 |
|
"modules.test.paragraph.bar.type=jsp"; |
129 |
|
|
130 |
|
} |