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; |
35 |
|
|
36 |
|
import static info.magnolia.test.hamcrest.NodeMatchers.*; |
37 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
38 |
|
import static org.junit.Assert.*; |
39 |
|
|
40 |
|
import info.magnolia.context.MgnlContext; |
41 |
|
import info.magnolia.jcr.util.NodeTypes; |
42 |
|
import info.magnolia.jcr.util.NodeUtil; |
43 |
|
import info.magnolia.module.ModuleManagementException; |
44 |
|
import info.magnolia.module.ModuleVersionHandler; |
45 |
|
import info.magnolia.module.ModuleVersionHandlerTestCase; |
46 |
|
import info.magnolia.module.googlesitemap.GoogleSiteMapConfiguration; |
47 |
|
import info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.contentviews.formatter.FolderNameColumnFormatter; |
48 |
|
import info.magnolia.module.model.Version; |
49 |
|
import info.magnolia.repository.RepositoryConstants; |
50 |
|
|
51 |
|
import java.util.Arrays; |
52 |
|
import java.util.List; |
53 |
|
|
54 |
|
import javax.jcr.Node; |
55 |
|
import javax.jcr.NodeIterator; |
56 |
|
import javax.jcr.RepositoryException; |
57 |
|
import javax.jcr.Session; |
58 |
|
|
59 |
|
import org.junit.Test; |
60 |
|
|
61 |
|
|
62 |
|
@link |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (79) |
Complexity: 10 |
Complexity Density: 0.14 |
|
64 |
|
public class GoogleSiteMapVersionHandlerTest extends ModuleVersionHandlerTestCase { |
65 |
|
private Session session; |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
5 |
@Override... |
67 |
|
protected String getModuleDescriptorPath() { |
68 |
5 |
return "/META-INF/magnolia/google-sitemap.xml"; |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
5 |
@Override... |
72 |
|
protected ModuleVersionHandler newModuleVersionHandlerForTests() { |
73 |
5 |
return new GoogleSiteMapVersionHandler(); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
5 |
@Override... |
77 |
|
protected String[] getExtraWorkspaces() { |
78 |
5 |
return new String[] { "templates" }; |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
5 |
@Override... |
82 |
|
protected List<String> getModuleDescriptorPathsForTests() { |
83 |
5 |
return Arrays.asList("/META-INF/magnolia/core.xml"); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
86 |
5 |
@Override... |
87 |
|
public void setUp() throws Exception { |
88 |
5 |
super.setUp(); |
89 |
5 |
session = MgnlContext.getJCRSession(RepositoryConstants.CONFIG); |
90 |
5 |
addSupportForSetupModuleRepositoriesTask(GoogleSiteMapConfiguration.WORKSPACE); |
91 |
5 |
this.setupConfigProperty("/modules/google-sitemap/dialogs/components/content/siteComponentTab/form/tabs/tabSites/fields/sites/field", "workspace", "website"); |
92 |
5 |
this.setupConfigNode("/modules/google-sitemap/dialogs/generic/controls/googleSiteMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapPriority"); |
93 |
5 |
this.setupConfigNode("/modules/google-sitemap/dialogs/generic/controls/googleSiteMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapChangefreq"); |
94 |
5 |
this.setupConfigNode("/modules/google-sitemap/dialogs/generic/controls/googleVirtualUriMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapPriority"); |
95 |
5 |
this.setupConfigNode("/modules/google-sitemap/dialogs/generic/controls/googleVirtualUriMapTab/form/tabs/tabGoogleSitemapProps/fields/googleSitemapChangefreq"); |
96 |
5 |
this.setupConfigNode("/modules/google-sitemap/templates/pages/siteMapsConfiguration"); |
97 |
5 |
this.setupConfigNode("/modules/google-sitemap/apps/siteMaps/subApps/browser/actions/deactivate"); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
100 |
1 |
@Test... |
101 |
|
public void testUpdateTo20ReordersSitemapBeforeConfigApp() throws Exception { |
102 |
|
|
103 |
1 |
Node manageApps = NodeUtil.createPath(session.getRootNode(), "modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps", NodeTypes.ContentNode.NAME); |
104 |
1 |
NodeUtil.createPath(manageApps, "rssAggregator", NodeTypes.ContentNode.NAME); |
105 |
1 |
NodeUtil.createPath(manageApps, "configuration", NodeTypes.ContentNode.NAME); |
106 |
|
|
107 |
|
|
108 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("1.2.3")); |
109 |
|
|
110 |
|
|
111 |
1 |
NodeIterator it = manageApps.getNodes(); |
112 |
1 |
assertTrue(manageApps.hasNode("siteMaps")); |
113 |
1 |
assertEquals("rssAggregator", it.nextNode().getName()); |
114 |
1 |
assertEquals("siteMaps", it.nextNode().getName()); |
115 |
1 |
assertEquals("configuration", it.nextNode().getName()); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
118 |
1 |
@Test... |
119 |
|
public void testFreshInstallReordersSitemapBeforeConfigApp() throws Exception { |
120 |
|
|
121 |
1 |
Node manageApps = NodeUtil.createPath(session.getRootNode(), "modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps", NodeTypes.ContentNode.NAME); |
122 |
1 |
NodeUtil.createPath(manageApps, "rssAggregator", NodeTypes.ContentNode.NAME); |
123 |
1 |
NodeUtil.createPath(manageApps, "configuration", NodeTypes.ContentNode.NAME); |
124 |
|
|
125 |
1 |
NodeUtil.createPath(manageApps, "siteMaps", NodeTypes.ContentNode.NAME); |
126 |
|
|
127 |
|
|
128 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(null); |
129 |
|
|
130 |
|
|
131 |
1 |
NodeIterator it = manageApps.getNodes(); |
132 |
1 |
assertTrue(manageApps.hasNode("siteMaps")); |
133 |
1 |
assertEquals("rssAggregator", it.nextNode().getName()); |
134 |
1 |
assertEquals("siteMaps", it.nextNode().getName()); |
135 |
1 |
assertEquals("configuration", it.nextNode().getName()); |
136 |
|
} |
137 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
138 |
1 |
@Test... |
139 |
|
public void testUpdateTo22() throws RepositoryException, ModuleManagementException { |
140 |
|
|
141 |
1 |
this.setupConfigProperty("/modules/google-sitemap/dialogs/components/content/siteComponentTab/form/tabs/siteMap", "property", "value"); |
142 |
1 |
this.setupConfigNode("/modules/google-sitemap/apps/siteMaps/subApps/browser"); |
143 |
1 |
this.setupConfigProperty("/modules/google-sitemap/apps/siteMaps/subApps/pages", "property", "value"); |
144 |
1 |
this.setupConfigProperty("/modules/google-sitemap/apps/siteMaps/subApps/browser/workbench/contentViews/list/columns/name", "formatterClass", "info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.formatter.FolderNameColumnFormatter"); |
145 |
|
|
146 |
|
|
147 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0")); |
148 |
|
|
149 |
|
|
150 |
1 |
NodeIterator it = session.getNode("/modules/google-sitemap/apps/siteMaps/subApps").getNodes(); |
151 |
1 |
assertEquals("browser", it.nextNode().getName()); |
152 |
1 |
assertEquals("pages", it.nextNode().getName()); |
153 |
1 |
assertConfig(FolderNameColumnFormatter.class.getName(), "/modules/google-sitemap/apps/siteMaps/subApps/browser/workbench/contentViews/list/columns/name/formatterClass"); |
154 |
1 |
assertConfig("0.5", "/modules/google-sitemap/config/priority"); |
155 |
1 |
assertConfig("weekly", "/modules/google-sitemap/config/changeFrequency"); |
156 |
1 |
assertTrue(session.nodeExists("/modules/google-sitemap/fieldTypes/siteMapSelect")); |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
159 |
1 |
@Test... |
160 |
|
public void testUpdateTo22ConfigureActions() throws Exception { |
161 |
|
|
162 |
1 |
Session session = MgnlContext.getJCRSession(RepositoryConstants.CONFIG); |
163 |
1 |
this.setupConfigProperty("/modules/google-sitemap/apps/siteMaps/subApps/browser/workbench/contentViews/list/columns/name", "formatterClass", "info.magnolia.module.googlesitemap.app.subapp.sitemapdetail.formatter.FolderNameColumnFormatter"); |
164 |
1 |
Node addSiteMapAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "addSiteMap", NodeTypes.ContentNode.NAME); |
165 |
1 |
Node deleteAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "delete", NodeTypes.ContentNode.NAME); |
166 |
1 |
Node editSiteMapAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "editSiteMap", NodeTypes.ContentNode.NAME); |
167 |
1 |
Node activateAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "activate", NodeTypes.ContentNode.NAME); |
168 |
1 |
Node deactivateAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "deactivate", NodeTypes.ContentNode.NAME); |
169 |
1 |
Node activateDeletedAction = NodeUtil.createPath(session.getRootNode(), GoogleSiteMapVersionHandler.GOOGLESITEMAP_APP_BROWSER_ACTIONS + "activateDeleted", NodeTypes.ContentNode.NAME); |
170 |
|
|
171 |
|
|
172 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.1")); |
173 |
|
|
174 |
|
|
175 |
1 |
assertThat(addSiteMapAction, hasNode("availability")); |
176 |
1 |
assertThat(addSiteMapAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
177 |
1 |
assertThat(deleteAction, hasNode("availability")); |
178 |
1 |
assertThat(deleteAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
179 |
1 |
assertThat(editSiteMapAction, hasNode("availability")); |
180 |
1 |
assertThat(editSiteMapAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
181 |
1 |
assertThat(activateAction, hasNode("availability")); |
182 |
1 |
assertThat(activateAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
183 |
1 |
assertThat(deactivateAction, hasNode("availability")); |
184 |
1 |
assertThat(deactivateAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
185 |
1 |
assertThat(activateDeletedAction, hasNode("availability")); |
186 |
1 |
assertThat(activateDeletedAction.getNode("availability"), hasProperty("writePermissionRequired", true)); |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
189 |
1 |
@Test... |
190 |
|
public void testUpdateTo223NewCatalogProperty() throws RepositoryException, ModuleManagementException { |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.2.2")); |
195 |
|
|
196 |
|
|
197 |
1 |
assertTrue(session.propertyExists("/modules/google-sitemap/apps/siteMaps/subApps/browser/actions/deactivate/catalog")); |
198 |
1 |
assertEquals("website",session.getProperty("/modules/google-sitemap/apps/siteMaps/subApps/browser/actions/deactivate/catalog").getString()); |
199 |
|
} |
200 |
|
} |