1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.model.internal.reference; |
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.component.util.ReflectionUtils; |
27 |
|
import org.xwiki.model.EntityType; |
28 |
|
import org.xwiki.model.reference.ClassPropertyReference; |
29 |
|
import org.xwiki.model.reference.DocumentReference; |
30 |
|
import org.xwiki.model.reference.EntityReference; |
31 |
|
import org.xwiki.model.reference.EntityReferenceProvider; |
32 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
33 |
|
import org.xwiki.model.reference.ObjectPropertyReference; |
34 |
|
import org.xwiki.model.reference.SpaceReference; |
35 |
|
import org.xwiki.model.reference.WikiReference; |
36 |
|
import org.xwiki.model.reference.test.TestConstants; |
37 |
|
import org.xwiki.test.annotation.ComponentList; |
38 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
39 |
|
|
40 |
|
import static org.mockito.Mockito.*; |
41 |
|
import static org.junit.Assert.*; |
42 |
|
|
43 |
|
|
44 |
|
@link |
45 |
|
|
46 |
|
@version |
47 |
|
@since |
48 |
|
|
49 |
|
@ComponentList({ |
50 |
|
DefaultSymbolScheme.class |
51 |
|
}) |
|
|
| 100% |
Uncovered Elements: 0 (288) |
Complexity: 9 |
Complexity Density: 0.03 |
|
52 |
|
public class DefaultStringEntityReferenceResolverTest implements TestConstants |
53 |
|
{ |
54 |
|
@Rule |
55 |
|
public MockitoComponentMockingRule<DefaultStringEntityReferenceResolver> mocker = |
56 |
|
new MockitoComponentMockingRule<>(DefaultStringEntityReferenceResolver.class); |
57 |
|
|
58 |
|
private EntityReferenceResolver<String> resolver; |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
60 |
8 |
@Before... |
61 |
|
public void setUp() throws Exception |
62 |
|
{ |
63 |
8 |
this.resolver = this.mocker.getComponentUnderTest(); |
64 |
|
|
65 |
8 |
EntityReferenceProvider referenceProvider = mock(EntityReferenceProvider.class); |
66 |
8 |
ReflectionUtils.setFieldValue(this.resolver, "provider", referenceProvider); |
67 |
|
|
68 |
8 |
when(referenceProvider.getDefaultReference(EntityType.WIKI)).thenReturn(DEFAULT_WIKI_REFERENCE); |
69 |
8 |
when(referenceProvider.getDefaultReference(EntityType.SPACE)).thenReturn(DEFAULT_SPACE_REFERENCE); |
70 |
8 |
when(referenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(DEFAULT_PAGE_REFERENCE); |
71 |
8 |
when(referenceProvider.getDefaultReference(EntityType.ATTACHMENT)).thenReturn(DEFAULT_ATTACHMENT_REFERENCE); |
72 |
8 |
when(referenceProvider.getDefaultReference(EntityType.OBJECT)).thenReturn(DEFAULT_OBJECT_REFERENCE); |
73 |
8 |
when(referenceProvider.getDefaultReference(EntityType.OBJECT_PROPERTY)).thenReturn( |
74 |
|
DEFAULT_OBJECT_PROPERTY_REFERENCE); |
75 |
8 |
when(referenceProvider.getDefaultReference(EntityType.CLASS_PROPERTY)).thenReturn( |
76 |
|
DEFAULT_CLASS_PROPERTY_REFERENCE); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (58) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
79 |
1 |
@Test... |
80 |
|
public void testResolveDocumentReference() throws Exception |
81 |
|
{ |
82 |
1 |
EntityReference reference = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); |
83 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
84 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
85 |
1 |
assertEquals("page", reference.getName()); |
86 |
|
|
87 |
1 |
reference = resolver.resolve("wiki:space.", EntityType.DOCUMENT); |
88 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
89 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
90 |
1 |
assertEquals(DEFAULT_PAGE, reference.getName()); |
91 |
|
|
92 |
1 |
reference = resolver.resolve("space.", EntityType.DOCUMENT); |
93 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
94 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
95 |
1 |
assertEquals(DEFAULT_PAGE, reference.getName()); |
96 |
|
|
97 |
1 |
reference = resolver.resolve("page", EntityType.DOCUMENT); |
98 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
99 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
100 |
1 |
assertEquals("page", reference.getName()); |
101 |
|
|
102 |
1 |
reference = resolver.resolve(".", EntityType.DOCUMENT); |
103 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
104 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
105 |
1 |
assertEquals(DEFAULT_PAGE, reference.getName()); |
106 |
|
|
107 |
1 |
reference = resolver.resolve(null, EntityType.DOCUMENT); |
108 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
109 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
110 |
1 |
assertEquals(DEFAULT_PAGE, reference.getName()); |
111 |
|
|
112 |
1 |
reference = resolver.resolve("", EntityType.DOCUMENT); |
113 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
114 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
115 |
1 |
assertEquals(DEFAULT_PAGE, reference.getName()); |
116 |
|
|
117 |
1 |
reference = resolver.resolve("wiki1.wiki2:wiki3:some.space.page", EntityType.DOCUMENT); |
118 |
1 |
assertEquals("wiki1.wiki2:wiki3", reference.extractReference(EntityType.WIKI).getName()); |
119 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
120 |
1 |
assertEquals("some", reference.extractReference(EntityType.SPACE).getParent().getName()); |
121 |
1 |
assertEquals("page", reference.getName()); |
122 |
|
|
123 |
1 |
reference = resolver.resolve("some.space.page", EntityType.DOCUMENT); |
124 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
125 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
126 |
1 |
assertEquals("some", reference.extractReference(EntityType.SPACE).getParent().getName()); |
127 |
1 |
assertEquals("page", reference.getName()); |
128 |
|
|
129 |
1 |
reference = resolver.resolve("wiki:page", EntityType.DOCUMENT); |
130 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
131 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
132 |
1 |
assertEquals("wiki:page", reference.getName()); |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
1 |
reference = resolver.resolve("\\\\\\.:@\\.", EntityType.DOCUMENT); |
137 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
138 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
139 |
1 |
assertEquals("\\.:@.", reference.getName()); |
140 |
|
|
141 |
1 |
reference = resolver.resolve("some\\.space.page", EntityType.DOCUMENT); |
142 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
143 |
1 |
assertEquals("some.space", reference.extractReference(EntityType.SPACE).getName()); |
144 |
1 |
assertEquals("page", reference.getName()); |
145 |
|
|
146 |
|
|
147 |
1 |
reference = resolver.resolve("\\\\:\\\\.\\\\", EntityType.DOCUMENT); |
148 |
1 |
assertEquals("\\", reference.extractReference(EntityType.WIKI).getName()); |
149 |
1 |
assertEquals("\\", reference.extractReference(EntityType.SPACE).getName()); |
150 |
1 |
assertEquals("\\", reference.getName()); |
151 |
|
|
152 |
1 |
reference = resolver.resolve("\\wiki:\\space.\\page", EntityType.DOCUMENT); |
153 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
154 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
155 |
1 |
assertEquals("page", reference.getName()); |
156 |
|
} |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
158 |
1 |
@Test... |
159 |
|
public void testResolveAttachmentReference() throws Exception |
160 |
|
{ |
161 |
1 |
EntityReference reference = resolver.resolve("wiki:space.page@filename.ext", EntityType.ATTACHMENT); |
162 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
163 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
164 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
165 |
1 |
assertEquals("filename.ext", reference.getName()); |
166 |
|
|
167 |
1 |
reference = resolver.resolve("", EntityType.ATTACHMENT); |
168 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
169 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
170 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
171 |
1 |
assertEquals(DEFAULT_ATTACHMENT, reference.getName()); |
172 |
|
|
173 |
1 |
reference = resolver.resolve("wiki:space.page@my.png", EntityType.ATTACHMENT); |
174 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
175 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
176 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
177 |
1 |
assertEquals("my.png", reference.getName()); |
178 |
|
|
179 |
1 |
reference = resolver.resolve("some:file.name", EntityType.ATTACHMENT); |
180 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
181 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
182 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
183 |
1 |
assertEquals("some:file.name", reference.getName()); |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
1 |
reference = resolver.resolve(":.\\@", EntityType.ATTACHMENT); |
188 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
189 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
190 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
191 |
1 |
assertEquals(":.@", reference.getName()); |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (50) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
197 |
1 |
@Test... |
198 |
|
public void testResolveObjectReference() |
199 |
|
{ |
200 |
1 |
EntityReference reference = resolver.resolve("wiki:space.page^Object", EntityType.OBJECT); |
201 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
202 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
203 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
204 |
1 |
assertEquals("Object", reference.getName()); |
205 |
|
|
206 |
|
|
207 |
1 |
reference = resolver.resolve("", EntityType.OBJECT); |
208 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
209 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
210 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
211 |
1 |
assertEquals(DEFAULT_OBJECT, reference.getName()); |
212 |
|
|
213 |
|
|
214 |
1 |
reference = resolver.resolve("space.page^Object", EntityType.OBJECT); |
215 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
216 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
217 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
218 |
1 |
assertEquals("Object", reference.getName()); |
219 |
|
|
220 |
1 |
reference = resolver.resolve("page^Object", EntityType.OBJECT); |
221 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
222 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
223 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
224 |
1 |
assertEquals("Object", reference.getName()); |
225 |
|
|
226 |
1 |
reference = resolver.resolve("XWiki.Class", EntityType.OBJECT); |
227 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
228 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
229 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
230 |
1 |
assertEquals("XWiki.Class", reference.getName()); |
231 |
|
|
232 |
|
|
233 |
1 |
reference = resolver.resolve("wiki:space.page.property", EntityType.OBJECT); |
234 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
235 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
236 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
237 |
1 |
assertEquals("wiki:space.page.property", reference.getName()); |
238 |
|
|
239 |
|
|
240 |
1 |
reference = resolver.resolve("wiki:space.page^", EntityType.OBJECT); |
241 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
242 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
243 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
244 |
1 |
assertEquals(DEFAULT_OBJECT, reference.getName()); |
245 |
|
|
246 |
|
|
247 |
1 |
reference = resolver.resolve("wiki:space.page^obje\\^ct", EntityType.OBJECT); |
248 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
249 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
250 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
251 |
1 |
assertEquals("obje^ct", reference.getName()); |
252 |
|
|
253 |
|
|
254 |
1 |
reference = resolver.resolve("wiki:spa^ce.page^Object", EntityType.OBJECT); |
255 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
256 |
1 |
assertEquals("spa^ce", reference.extractReference(EntityType.SPACE).getName()); |
257 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
258 |
1 |
assertEquals("Object", reference.getName()); |
259 |
|
|
260 |
1 |
reference = resolver.resolve(":.\\^@", EntityType.OBJECT); |
261 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
262 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
263 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
264 |
1 |
assertEquals(":.^@", reference.getName()); |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (66) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
270 |
1 |
@Test... |
271 |
|
public void testResolveObjectPropertyReference() |
272 |
|
{ |
273 |
1 |
EntityReference reference = |
274 |
|
new ObjectPropertyReference(resolver.resolve("wiki:space.page^object.prop", EntityType.OBJECT_PROPERTY)); |
275 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
276 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
277 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
278 |
1 |
assertEquals("object", reference.extractReference(EntityType.OBJECT).getName()); |
279 |
1 |
assertEquals("prop", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
280 |
|
|
281 |
|
|
282 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("", EntityType.OBJECT_PROPERTY)); |
283 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
284 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
285 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
286 |
1 |
assertEquals(DEFAULT_OBJECT, reference.extractReference(EntityType.OBJECT).getName()); |
287 |
1 |
assertEquals(DEFAULT_OBJECT_PROPERTY, reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
288 |
|
|
289 |
|
|
290 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("space.page^Object.prop", EntityType.OBJECT_PROPERTY)); |
291 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
292 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
293 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
294 |
1 |
assertEquals("Object", reference.extractReference(EntityType.OBJECT).getName()); |
295 |
1 |
assertEquals("prop", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
296 |
|
|
297 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("page^Object.prop", EntityType.OBJECT_PROPERTY)); |
298 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
299 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
300 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
301 |
1 |
assertEquals("Object", reference.extractReference(EntityType.OBJECT).getName()); |
302 |
1 |
assertEquals("prop", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
303 |
|
|
304 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("Object.prop", EntityType.OBJECT_PROPERTY)); |
305 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
306 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
307 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
308 |
1 |
assertEquals("Object", reference.extractReference(EntityType.OBJECT).getName()); |
309 |
1 |
assertEquals("prop", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
310 |
|
|
311 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("FooBar", EntityType.OBJECT_PROPERTY)); |
312 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
313 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
314 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
315 |
1 |
assertEquals(DEFAULT_OBJECT, reference.extractReference(EntityType.OBJECT).getName()); |
316 |
1 |
assertEquals("FooBar", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
317 |
|
|
318 |
|
|
319 |
1 |
reference = new ObjectPropertyReference(resolver.resolve("page^Object", EntityType.OBJECT_PROPERTY)); |
320 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
321 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
322 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
323 |
1 |
assertEquals(DEFAULT_OBJECT, reference.extractReference(EntityType.OBJECT).getName()); |
324 |
1 |
assertEquals("page^Object", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
325 |
|
|
326 |
|
|
327 |
1 |
reference = |
328 |
|
new ObjectPropertyReference(resolver.resolve("wiki:space.page^Object.", EntityType.OBJECT_PROPERTY)); |
329 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
330 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
331 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
332 |
1 |
assertEquals("Object", reference.extractReference(EntityType.OBJECT).getName()); |
333 |
1 |
assertEquals(DEFAULT_OBJECT_PROPERTY, reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
334 |
|
|
335 |
|
|
336 |
1 |
reference = |
337 |
|
new ObjectPropertyReference(resolver.resolve("wiki:space.page^Object.prop\\.erty", |
338 |
|
EntityType.OBJECT_PROPERTY)); |
339 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
340 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
341 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
342 |
1 |
assertEquals("Object", reference.extractReference(EntityType.OBJECT).getName()); |
343 |
1 |
assertEquals("prop.erty", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
344 |
|
|
345 |
|
|
346 |
1 |
reference = |
347 |
|
new ObjectPropertyReference(resolver.resolve("wiki:space.page^x.wiki.class[0].prop", |
348 |
|
EntityType.OBJECT_PROPERTY)); |
349 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
350 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
351 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
352 |
1 |
assertEquals("x.wiki.class[0]", reference.extractReference(EntityType.OBJECT).getName()); |
353 |
1 |
assertEquals("prop", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
354 |
|
|
355 |
1 |
reference = new ObjectPropertyReference(resolver.resolve(":^\\.@", EntityType.OBJECT_PROPERTY)); |
356 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
357 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
358 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
359 |
1 |
assertEquals(DEFAULT_OBJECT, reference.extractReference(EntityType.OBJECT).getName()); |
360 |
1 |
assertEquals(":^.@", reference.extractReference(EntityType.OBJECT_PROPERTY).getName()); |
361 |
|
} |
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (50) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
366 |
1 |
@Test... |
367 |
|
public void testResolveClassPropertyReference() |
368 |
|
{ |
369 |
1 |
EntityReference reference = |
370 |
|
new ClassPropertyReference(resolver.resolve("wiki:space.page^ClassProp", EntityType.CLASS_PROPERTY)); |
371 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
372 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
373 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
374 |
1 |
assertEquals("ClassProp", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
375 |
|
|
376 |
|
|
377 |
1 |
reference = new ClassPropertyReference(resolver.resolve("", EntityType.CLASS_PROPERTY)); |
378 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
379 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
380 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
381 |
1 |
assertEquals(DEFAULT_CLASS_PROPERTY, reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
382 |
|
|
383 |
|
|
384 |
1 |
reference = new ClassPropertyReference(resolver.resolve("space.page^ClassProp", EntityType.CLASS_PROPERTY)); |
385 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
386 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
387 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
388 |
1 |
assertEquals("ClassProp", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
389 |
|
|
390 |
1 |
reference = new ClassPropertyReference(resolver.resolve("page^ClassProp", EntityType.CLASS_PROPERTY)); |
391 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
392 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
393 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
394 |
1 |
assertEquals("ClassProp", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
395 |
|
|
396 |
1 |
reference = new ClassPropertyReference(resolver.resolve("XWiki.Class", EntityType.CLASS_PROPERTY)); |
397 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
398 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
399 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
400 |
1 |
assertEquals("XWiki.Class", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
401 |
|
|
402 |
|
|
403 |
1 |
reference = new ClassPropertyReference(resolver.resolve("wiki:space.page.property", EntityType.CLASS_PROPERTY)); |
404 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
405 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
406 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
407 |
1 |
Assert |
408 |
|
.assertEquals("wiki:space.page.property", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
409 |
|
|
410 |
|
|
411 |
1 |
reference = new ClassPropertyReference(resolver.resolve("wiki:space.page^", EntityType.CLASS_PROPERTY)); |
412 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
413 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
414 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
415 |
1 |
assertEquals(DEFAULT_CLASS_PROPERTY, reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
416 |
|
|
417 |
|
|
418 |
1 |
reference = |
419 |
|
new ClassPropertyReference(resolver.resolve("wiki:space.page^obje\\^ct", EntityType.CLASS_PROPERTY)); |
420 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
421 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
422 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
423 |
1 |
assertEquals("obje^ct", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
424 |
|
|
425 |
|
|
426 |
1 |
reference = |
427 |
|
new ClassPropertyReference(resolver.resolve("wiki:spa^ce.page^ClassProp", EntityType.CLASS_PROPERTY)); |
428 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
429 |
1 |
assertEquals("spa^ce", reference.extractReference(EntityType.SPACE).getName()); |
430 |
1 |
assertEquals("page", reference.extractReference(EntityType.DOCUMENT).getName()); |
431 |
1 |
assertEquals("ClassProp", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
432 |
|
|
433 |
1 |
reference = new ClassPropertyReference(resolver.resolve(":.\\^@", EntityType.CLASS_PROPERTY)); |
434 |
1 |
assertEquals(DEFAULT_WIKI, reference.extractReference(EntityType.WIKI).getName()); |
435 |
1 |
assertEquals(DEFAULT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
436 |
1 |
assertEquals(DEFAULT_PAGE, reference.extractReference(EntityType.DOCUMENT).getName()); |
437 |
1 |
assertEquals(":.^@", reference.extractReference(EntityType.CLASS_PROPERTY).getName()); |
438 |
|
} |
439 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
440 |
1 |
@Test... |
441 |
|
public void testResolveDocumentReferenceWithExplicitReference() |
442 |
|
{ |
443 |
1 |
EntityReference reference = |
444 |
|
resolver.resolve("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, |
445 |
|
new EntityReference("wiki", EntityType.WIKI))); |
446 |
1 |
assertEquals("wiki", reference.extractReference(EntityType.WIKI).getName()); |
447 |
1 |
assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
448 |
1 |
assertEquals("page", reference.getName()); |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
454 |
1 |
@Test... |
455 |
|
public void testResolveSpaceReference() |
456 |
|
{ |
457 |
1 |
SpaceReference reference = new SpaceReference(this.resolver.resolve("space", EntityType.SPACE)); |
458 |
1 |
assertEquals("space", reference.getName()); |
459 |
|
|
460 |
|
|
461 |
1 |
reference = new SpaceReference(this.resolver.resolve("space1.space2", EntityType.SPACE)); |
462 |
1 |
assertEquals("space2", reference.getName()); |
463 |
1 |
assertEquals("space1", reference.getParent().getName()); |
464 |
|
} |
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
469 |
1 |
@Test... |
470 |
|
public void testResolveWikiReference() |
471 |
|
{ |
472 |
1 |
WikiReference reference = new WikiReference(resolver.resolve("dev", EntityType.WIKI)); |
473 |
1 |
assertEquals("dev", reference.getName()); |
474 |
|
|
475 |
|
|
476 |
1 |
reference = new WikiReference(resolver.resolve("", EntityType.WIKI)); |
477 |
1 |
assertEquals(DEFAULT_WIKI, reference.getName()); |
478 |
|
|
479 |
|
|
480 |
1 |
DocumentReference baseReference = new DocumentReference("math", "Theorems", "Pitagora"); |
481 |
1 |
reference = new WikiReference(resolver.resolve("", EntityType.WIKI, baseReference)); |
482 |
1 |
assertEquals(baseReference.getWikiReference(), reference); |
483 |
|
|
484 |
|
|
485 |
1 |
reference = new WikiReference(resolver.resolve("dev:lab.uix", EntityType.WIKI)); |
486 |
1 |
assertEquals("dev:lab.uix", reference.getName()); |
487 |
|
|
488 |
|
|
489 |
1 |
reference = new WikiReference(resolver.resolve("dev\\:lab\\.uix", EntityType.WIKI)); |
490 |
1 |
assertEquals("dev:lab.uix", reference.getName()); |
491 |
|
} |
492 |
|
} |