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.googlesitemap.setup.for2_1; |
35 |
|
|
36 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
37 |
|
|
38 |
|
import info.magnolia.context.MgnlContext; |
39 |
|
import info.magnolia.jcr.util.NodeTypes; |
40 |
|
import info.magnolia.module.InstallContextImpl; |
41 |
|
import info.magnolia.module.ModuleRegistryImpl; |
42 |
|
import info.magnolia.module.delta.TaskExecutionException; |
43 |
|
import info.magnolia.module.googlesitemap.SiteMapNodeTypes.GoogleSiteMap; |
44 |
|
import info.magnolia.repository.RepositoryConstants; |
45 |
|
import info.magnolia.test.RepositoryTestCase; |
46 |
|
import info.magnolia.test.hamcrest.NodeMatchers; |
47 |
|
|
48 |
|
import javax.jcr.Node; |
49 |
|
import javax.jcr.RepositoryException; |
50 |
|
import javax.jcr.Session; |
51 |
|
|
52 |
|
import org.junit.Before; |
53 |
|
import org.junit.Test; |
54 |
|
|
55 |
|
|
56 |
|
@link |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 3 |
Complexity Density: 0.11 |
|
58 |
|
public class RenameSiteMapeSitePagesPropertyNameTest extends RepositoryTestCase { |
59 |
|
|
60 |
|
private Session session; |
61 |
|
private InstallContextImpl installContext; |
62 |
|
private Node pageNode; |
63 |
|
private RenameSiteMapeSitePagesPropertyName task; |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
65 |
2 |
@Override... |
66 |
|
@Before |
67 |
|
public void setUp() throws Exception { |
68 |
2 |
super.setUp(); |
69 |
2 |
session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE); |
70 |
2 |
Node root = session.getRootNode(); |
71 |
2 |
pageNode = root.addNode("page", NodeTypes.Page.NAME); |
72 |
|
|
73 |
2 |
final ModuleRegistryImpl moduleRegistry = new ModuleRegistryImpl(); |
74 |
2 |
installContext = new InstallContextImpl(moduleRegistry); |
75 |
|
|
76 |
2 |
task = new RenameSiteMapeSitePagesPropertyName("taskName", "taskDescription", RepositoryConstants.WEBSITE); |
77 |
|
|
78 |
|
} |
79 |
|
|
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testSitePagePropertyUpdate() throws RepositoryException, TaskExecutionException { |
83 |
|
|
84 |
1 |
pageNode.setProperty("googleSitemapChangefreq", "googleSitemapChangefreq"); |
85 |
1 |
pageNode.setProperty("googleSitemapHide", "googleSitemapHide"); |
86 |
1 |
pageNode.setProperty("googleSitemapPriority", "googleSitemapPriority"); |
87 |
1 |
pageNode.setProperty("googleSitemapHideChildren", "googleSitemapHideChildren"); |
88 |
1 |
pageNode.setProperty("tutu", "tutu"); |
89 |
1 |
session.save(); |
90 |
|
|
91 |
|
|
92 |
1 |
task.execute(installContext); |
93 |
|
|
94 |
|
|
95 |
1 |
pageNode = session.getNode("/page"); |
96 |
1 |
assertThat(pageNode, NodeMatchers.hasProperty(GoogleSiteMap.SITEMAP_CHANGEFREQ, "googleSitemapChangefreq")); |
97 |
1 |
assertThat(pageNode, NodeMatchers.hasProperty(GoogleSiteMap.SITEMAP_HIDE_IN_GOOGLESITEMAP, "googleSitemapHide")); |
98 |
1 |
assertThat(pageNode, NodeMatchers.hasProperty(GoogleSiteMap.SITEMAP_PRIORITY, "googleSitemapPriority")); |
99 |
1 |
assertThat(pageNode, NodeMatchers.hasProperty(GoogleSiteMap.SITEMAP_HIDE_IN_GOOGLESITEMAP_CHILDREN, "googleSitemapHideChildren")); |
100 |
1 |
assertThat(pageNode, NodeMatchers.hasProperty("tutu", "tutu")); |
101 |
|
} |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
103 |
1 |
@Test... |
104 |
|
public void testNoUpdate() throws RepositoryException, TaskExecutionException { |
105 |
|
|
106 |
1 |
Node contentNode = session.getRootNode().addNode("contentNode", NodeTypes.ContentNode.NAME); |
107 |
1 |
contentNode.setProperty("googleSitemapChangefreq", "googleSitemapChangefreq"); |
108 |
1 |
contentNode.setProperty("tutu", "tutu"); |
109 |
1 |
session.save(); |
110 |
|
|
111 |
|
|
112 |
1 |
task.execute(installContext); |
113 |
|
|
114 |
|
|
115 |
1 |
contentNode = session.getNode("/contentNode"); |
116 |
1 |
assertThat(contentNode, NodeMatchers.hasProperty("googleSitemapChangefreq", "googleSitemapChangefreq")); |
117 |
1 |
assertThat(contentNode, NodeMatchers.hasProperty("tutu", "tutu")); |
118 |
|
} |
119 |
|
} |