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.service; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
|
38 |
|
import info.magnolia.module.googlesitemap.SiteMapNodeTypes; |
39 |
|
import info.magnolia.module.googlesitemap.bean.SiteMapEntry; |
40 |
|
|
41 |
|
import java.util.Collections; |
42 |
|
import java.util.List; |
43 |
|
|
44 |
|
import javax.jcr.Node; |
45 |
|
import javax.jcr.RepositoryException; |
46 |
|
|
47 |
|
import org.apache.commons.collections.IteratorUtils; |
48 |
|
import org.junit.Test; |
49 |
|
|
50 |
|
|
51 |
|
@link |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (104) |
Complexity: 6 |
Complexity Density: 0.06 |
|
53 |
|
public class SiteMapServiceTest extends ServiceTestUtil { |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void testGetSiteMapBeansForPagesNotForEdit() throws RepositoryException { |
57 |
|
|
58 |
1 |
Node siteMapNode = googleSiteMapSession.getNode("/test1"); |
59 |
|
|
60 |
1 |
List<SiteMapEntry> res = service.getSiteMapBeans(siteMapNode, false, false); |
61 |
|
|
62 |
|
|
63 |
1 |
assertNotNull(res); |
64 |
|
|
65 |
1 |
assertEquals(2, res.size()); |
66 |
|
|
67 |
1 |
SiteMapEntry entry0 = res.get(0); |
68 |
1 |
assertEquals("always", entry0.getChangefreq()); |
69 |
1 |
assertEquals("2014-01-08", entry0.getLastmod()); |
70 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/article1", entry0.getLoc()); |
71 |
1 |
assertEquals("/demo-site/article/article1", entry0.getPath()); |
72 |
1 |
assertEquals(0.3d, entry0.getPriority(), 0); |
73 |
1 |
assertEquals(1, entry0.getLevel()); |
74 |
|
|
75 |
1 |
SiteMapEntry entry1 = res.get(1); |
76 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/articleSection", entry1.getLoc()); |
77 |
1 |
assertEquals("/demo-site/article/articleSection", entry1.getPath()); |
78 |
|
|
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testGetSiteMapBeansForPagesForEdit() throws RepositoryException { |
83 |
|
|
84 |
1 |
Node siteMapNode = googleSiteMapSession.getNode("/test1"); |
85 |
|
|
86 |
1 |
List<SiteMapEntry> res = service.getSiteMapBeans(siteMapNode, false, true); |
87 |
|
|
88 |
|
|
89 |
1 |
assertNotNull(res); |
90 |
1 |
assertEquals(4, res.size()); |
91 |
|
|
92 |
1 |
SiteMapEntry entry0 = res.get(0); |
93 |
1 |
assertEquals("always", entry0.getChangefreq()); |
94 |
1 |
assertEquals("2014-01-08", entry0.getLastmod()); |
95 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/article1", entry0.getLoc()); |
96 |
1 |
assertEquals("/demo-site/article/article1", entry0.getPath()); |
97 |
1 |
assertEquals(0.3d, entry0.getPriority(), 0); |
98 |
1 |
assertEquals(1, entry0.getLevel()); |
99 |
1 |
assertFalse(entry0.isStyleAlert()); |
100 |
|
|
101 |
1 |
SiteMapEntry entry1 = res.get(1); |
102 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/article2", entry1.getLoc()); |
103 |
1 |
assertTrue(entry1.isStyleAlert()); |
104 |
1 |
assertEquals(0.8d, entry1.getPriority(), 0); |
105 |
1 |
assertEquals(1, entry1.getLevel()); |
106 |
|
|
107 |
1 |
SiteMapEntry entry2 = res.get(2); |
108 |
1 |
assertEquals("/demo-site/article/articleSection", entry2.getPath()); |
109 |
1 |
assertFalse(entry2.isStyleAlert()); |
110 |
1 |
assertEquals(1, entry2.getLevel()); |
111 |
|
|
112 |
1 |
SiteMapEntry entry3 = res.get(3); |
113 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/articleSection/article3", entry3.getLoc()); |
114 |
1 |
assertTrue(entry3.isStyleAlert()); |
115 |
1 |
assertEquals(2, entry3.getLevel()); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
118 |
1 |
@Test... |
119 |
|
public void testGetSiteMapBeansForUirNotForEdit() throws RepositoryException { |
120 |
|
|
121 |
1 |
Node siteMapNode = googleSiteMapSession.getNode("/test1"); |
122 |
|
|
123 |
1 |
List<SiteMapEntry> res = service.getSiteMapBeans(siteMapNode, true, false); |
124 |
|
|
125 |
|
|
126 |
1 |
assertNotNull(res); |
127 |
1 |
assertEquals(2, res.size()); |
128 |
|
|
129 |
1 |
SiteMapEntry entry0 = res.get(0); |
130 |
1 |
assertEquals("always", entry0.getChangefreq()); |
131 |
1 |
assertEquals("2008-06-12", entry0.getLastmod()); |
132 |
1 |
assertEquals("null/\\.magnolia/pages/messages\\.(.*)\\.js", entry0.getLoc()); |
133 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/messages", entry0.getPath()); |
134 |
1 |
assertEquals(0.8d, entry0.getPriority(), 0); |
135 |
1 |
assertEquals(4, entry0.getLevel()); |
136 |
1 |
assertFalse(entry0.isStyleAlert()); |
137 |
|
|
138 |
1 |
SiteMapEntry entry1 = res.get(1); |
139 |
1 |
assertEquals("null/.magnolia/dialogs/fileThumbnail.jpg", entry1.getLoc()); |
140 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/dialogsFileThumbnail", entry1.getPath()); |
141 |
|
} |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
143 |
1 |
@Test... |
144 |
|
public void testGetSiteMapBeansForUriNotForEdit() throws RepositoryException { |
145 |
|
|
146 |
1 |
Node siteMapNode = googleSiteMapSession.getNode("/test1"); |
147 |
|
|
148 |
1 |
List<SiteMapEntry> res = service.getSiteMapBeans(siteMapNode, true, false); |
149 |
|
|
150 |
|
|
151 |
1 |
assertNotNull(res); |
152 |
1 |
assertEquals(2, res.size()); |
153 |
|
|
154 |
1 |
SiteMapEntry entry0 = res.get(0); |
155 |
1 |
assertEquals("null/\\.magnolia/pages/messages\\.(.*)\\.js", entry0.getLoc()); |
156 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/messages", entry0.getPath()); |
157 |
1 |
assertEquals(4, entry0.getLevel()); |
158 |
1 |
assertFalse(entry0.isStyleAlert()); |
159 |
|
|
160 |
1 |
SiteMapEntry entry1 = res.get(1); |
161 |
1 |
assertEquals("null/.magnolia/dialogs/fileThumbnail.jpg", entry1.getLoc()); |
162 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/dialogsFileThumbnail", entry1.getPath()); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
165 |
1 |
@Test... |
166 |
|
public void testGetSiteMapBeansNotForEdit() throws RepositoryException { |
167 |
|
|
168 |
1 |
Node siteMapNode = googleSiteMapSession.getNode("/test1"); |
169 |
|
|
170 |
1 |
List<SiteMapEntry> res = IteratorUtils.toList(service.getSiteMapBeans(siteMapNode)); |
171 |
1 |
Collections.sort(res); |
172 |
|
|
173 |
|
|
174 |
1 |
assertNotNull(res); |
175 |
1 |
assertEquals(4, res.size()); |
176 |
|
|
177 |
1 |
SiteMapEntry entry0 = res.get(0); |
178 |
1 |
assertEquals("always", entry0.getChangefreq()); |
179 |
1 |
assertEquals("2008-06-12", entry0.getLastmod()); |
180 |
1 |
assertEquals("null/\\.magnolia/pages/messages\\.(.*)\\.js", entry0.getLoc()); |
181 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/messages", entry0.getPath()); |
182 |
1 |
assertEquals(0.8d, entry0.getPriority(), 0); |
183 |
1 |
assertEquals(4, entry0.getLevel()); |
184 |
1 |
assertFalse(entry0.isStyleAlert()); |
185 |
|
|
186 |
1 |
SiteMapEntry entry1 = res.get(1); |
187 |
1 |
assertEquals("null/.magnolia/dialogs/fileThumbnail.jpg", entry1.getLoc()); |
188 |
1 |
assertEquals("/modules/adminInterface/virtualURIMapping/dialogsFileThumbnail", entry1.getPath()); |
189 |
|
|
190 |
1 |
SiteMapEntry entry2 = res.get(2); |
191 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/articleSection", entry2.getLoc()); |
192 |
|
|
193 |
1 |
SiteMapEntry entry3 = res.get(3); |
194 |
1 |
assertEquals("defaultBaseUrl/demo-site/article/article1", entry3.getLoc()); |
195 |
|
} |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
197 |
1 |
@Test... |
198 |
|
public void testUpdatePageNode() throws RepositoryException { |
199 |
|
|
200 |
1 |
SiteMapEntry entry = new SiteMapEntry(); |
201 |
1 |
entry.setPath("/demo-site/article/article1"); |
202 |
1 |
entry.setChangefreq("changefreq"); |
203 |
1 |
entry.setPriority(0.5d); |
204 |
1 |
entry.setHide(true); |
205 |
1 |
entry.setHideChildren(true); |
206 |
|
|
207 |
|
|
208 |
1 |
service.updatePageNode(entry); |
209 |
|
|
210 |
|
|
211 |
1 |
Node node = websiteSession.getNode("/demo-site/article/article1"); |
212 |
1 |
assertTrue(SiteMapNodeTypes.GoogleSiteMap.isHide(node)); |
213 |
1 |
assertEquals("changefreq", SiteMapNodeTypes.GoogleSiteMap.getChangeFreq(node)); |
214 |
1 |
assertEquals(0.5d, SiteMapNodeTypes.GoogleSiteMap.getPriority(node), 0); |
215 |
1 |
assertTrue(SiteMapNodeTypes.GoogleSiteMap.isHideChildren(node)); |
216 |
|
} |
217 |
|
|
218 |
|
} |