1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.search.solr.internal.reference; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.HashMap; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Locale; |
27 |
|
import java.util.Map; |
28 |
|
|
29 |
|
import javax.inject.Provider; |
30 |
|
|
31 |
|
import org.hamcrest.Matchers; |
32 |
|
import org.junit.Assert; |
33 |
|
import org.junit.Before; |
34 |
|
import org.junit.Rule; |
35 |
|
import org.junit.Test; |
36 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
37 |
|
import org.xwiki.context.Execution; |
38 |
|
import org.xwiki.context.ExecutionContext; |
39 |
|
import org.xwiki.context.internal.DefaultExecution; |
40 |
|
import org.xwiki.model.internal.DefaultModelConfiguration; |
41 |
|
import org.xwiki.model.internal.DefaultModelContext; |
42 |
|
import org.xwiki.model.internal.reference.DefaultEntityReferenceProvider; |
43 |
|
import org.xwiki.model.internal.reference.DefaultStringDocumentReferenceResolver; |
44 |
|
import org.xwiki.model.internal.reference.DefaultStringEntityReferenceResolver; |
45 |
|
import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer; |
46 |
|
import org.xwiki.model.internal.reference.DefaultSymbolScheme; |
47 |
|
import org.xwiki.model.internal.reference.ExplicitStringEntityReferenceResolver; |
48 |
|
import org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer; |
49 |
|
import org.xwiki.model.internal.reference.RelativeStringEntityReferenceResolver; |
50 |
|
import org.xwiki.model.reference.AttachmentReference; |
51 |
|
import org.xwiki.model.reference.DocumentReference; |
52 |
|
import org.xwiki.model.reference.EntityReference; |
53 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
54 |
|
import org.xwiki.model.reference.ObjectPropertyReference; |
55 |
|
import org.xwiki.model.reference.SpaceReference; |
56 |
|
import org.xwiki.model.reference.WikiReference; |
57 |
|
import org.xwiki.query.Query; |
58 |
|
import org.xwiki.query.QueryManager; |
59 |
|
import org.xwiki.query.internal.DefaultQuery; |
60 |
|
import org.xwiki.test.annotation.BeforeComponent; |
61 |
|
import org.xwiki.test.annotation.ComponentList; |
62 |
|
import org.xwiki.test.mockito.MockitoComponentManagerRule; |
63 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
64 |
|
|
65 |
|
import com.xpn.xwiki.XWiki; |
66 |
|
import com.xpn.xwiki.XWikiContext; |
67 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
68 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
69 |
|
import com.xpn.xwiki.internal.model.reference.CompactWikiStringEntityReferenceSerializer; |
70 |
|
import com.xpn.xwiki.internal.model.reference.CurrentEntityReferenceProvider; |
71 |
|
import com.xpn.xwiki.internal.model.reference.CurrentMixedEntityReferenceProvider; |
72 |
|
import com.xpn.xwiki.internal.model.reference.CurrentMixedStringDocumentReferenceResolver; |
73 |
|
import com.xpn.xwiki.internal.model.reference.CurrentReferenceDocumentReferenceResolver; |
74 |
|
import com.xpn.xwiki.internal.model.reference.CurrentReferenceEntityReferenceResolver; |
75 |
|
import com.xpn.xwiki.objects.BaseObject; |
76 |
|
import com.xpn.xwiki.objects.BaseObjectReference; |
77 |
|
import com.xpn.xwiki.objects.IntegerProperty; |
78 |
|
import com.xpn.xwiki.objects.StringProperty; |
79 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
80 |
|
import com.xpn.xwiki.web.Utils; |
81 |
|
|
82 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
83 |
|
import static org.hamcrest.Matchers.containsInAnyOrder; |
84 |
|
import static org.mockito.ArgumentMatchers.any; |
85 |
|
import static org.mockito.ArgumentMatchers.eq; |
86 |
|
import static org.mockito.Mockito.mock; |
87 |
|
import static org.mockito.Mockito.when; |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@version |
93 |
|
|
94 |
|
@ComponentList({ |
95 |
|
DefaultModelContext.class, |
96 |
|
DefaultModelConfiguration.class, |
97 |
|
LocalStringEntityReferenceSerializer.class, |
98 |
|
RelativeStringEntityReferenceResolver.class, |
99 |
|
CurrentReferenceDocumentReferenceResolver.class, |
100 |
|
CurrentReferenceEntityReferenceResolver.class, |
101 |
|
CurrentEntityReferenceProvider.class, |
102 |
|
CurrentMixedStringDocumentReferenceResolver.class, |
103 |
|
CurrentMixedEntityReferenceProvider.class, |
104 |
|
DefaultEntityReferenceProvider.class, |
105 |
|
CompactWikiStringEntityReferenceSerializer.class, |
106 |
|
DefaultStringDocumentReferenceResolver.class, |
107 |
|
DefaultStringEntityReferenceResolver.class, |
108 |
|
DefaultStringEntityReferenceSerializer.class, |
109 |
|
DefaultExecution.class, |
110 |
|
AttachmentSolrReferenceResolver.class, |
111 |
|
DefaultSolrReferenceResolver.class, |
112 |
|
DocumentSolrReferenceResolver.class, |
113 |
|
ObjectPropertySolrReferenceResolver.class, |
114 |
|
ObjectSolrReferenceResolver.class, |
115 |
|
SpaceSolrReferenceResolver.class, |
116 |
|
WikiSolrReferenceResolver.class, |
117 |
|
ExplicitStringEntityReferenceResolver.class, |
118 |
|
DefaultSymbolScheme.class |
119 |
|
}) |
|
|
| 100% |
Uncovered Elements: 0 (172) |
Complexity: 22 |
Complexity Density: 0.15 |
|
120 |
|
public class SolrReferenceResolverTest |
121 |
|
{ |
122 |
|
@Rule |
123 |
|
public final MockitoComponentManagerRule mocker = new MockitoComponentManagerRule(); |
124 |
|
|
125 |
|
private SolrReferenceResolver defaultSolrReferenceResolver; |
126 |
|
|
127 |
|
private XWikiContext xcontext; |
128 |
|
|
129 |
|
private XWiki xwiki; |
130 |
|
|
131 |
|
private WikiReference wikiReference1 = new WikiReference("wiki1"); |
132 |
|
|
133 |
|
private SpaceReference spaceReference11 = new SpaceReference("data", new SpaceReference("space11", wikiReference1)); |
134 |
|
|
135 |
|
private DocumentReference classReference111 = new DocumentReference("class111", spaceReference11); |
136 |
|
|
137 |
|
private DocumentReference documentReference111 = classReference111; |
138 |
|
|
139 |
|
private BaseClass xclass111; |
140 |
|
|
141 |
|
private XWikiDocument xdocument111; |
142 |
|
|
143 |
|
private DocumentReference documentReference112 = new DocumentReference("document112", spaceReference11); |
144 |
|
|
145 |
|
private XWikiDocument xdocument112; |
146 |
|
|
147 |
|
private DocumentReference documentReference113 = new DocumentReference("document113", spaceReference11); |
148 |
|
|
149 |
|
private DocumentReference documentReference113RO = new DocumentReference(documentReference113, new Locale("ro")); |
150 |
|
|
151 |
|
private XWikiDocument xdocument113 = null; |
152 |
|
|
153 |
|
private SpaceReference spaceReference12 = new SpaceReference("code", new SpaceReference("space12", wikiReference1)); |
154 |
|
|
155 |
|
private DocumentReference documentReference121 = new DocumentReference("document121", spaceReference12); |
156 |
|
|
157 |
|
private AttachmentReference attachmentReference1211 = new AttachmentReference("attachment1211.ext", |
158 |
|
documentReference121); |
159 |
|
|
160 |
|
private XWikiAttachment xattachment1211; |
161 |
|
|
162 |
|
private AttachmentReference attachmentReference1212 = new AttachmentReference("attachment1212.ext", |
163 |
|
documentReference121); |
164 |
|
|
165 |
|
private XWikiAttachment xattachment1212; |
166 |
|
|
167 |
|
private XWikiDocument xdocument121; |
168 |
|
|
169 |
|
private DocumentReference documentReference122 = new DocumentReference("document122", spaceReference12); |
170 |
|
|
171 |
|
private BaseObjectReference objectReference1221; |
172 |
|
|
173 |
|
private BaseObject xobject1221; |
174 |
|
|
175 |
|
private BaseObjectReference objectReference1222; |
176 |
|
|
177 |
|
private ObjectPropertyReference propertyReference12221; |
178 |
|
|
179 |
|
private StringProperty xproperty12221; |
180 |
|
|
181 |
|
private ObjectPropertyReference propertyReference12223; |
182 |
|
|
183 |
|
private IntegerProperty xproperty12223; |
184 |
|
|
185 |
|
private BaseObject xobject1222; |
186 |
|
|
187 |
|
private XWikiDocument xdocument122; |
188 |
|
|
189 |
|
private SpaceReference spaceReference13 = new SpaceReference("test", new SpaceReference("space13", wikiReference1)); |
190 |
|
|
191 |
|
private WikiReference wikiReference2 = new WikiReference("wiki2"); |
192 |
|
|
193 |
|
private QueryManager queryManager; |
194 |
|
|
195 |
|
private DocumentAccessBridge mockDAB; |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
197 |
20 |
@BeforeComponent... |
198 |
|
public void registerComponents() throws Exception |
199 |
|
{ |
200 |
20 |
this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER); |
201 |
20 |
this.mocker.registerMockComponent(QueryManager.class); |
202 |
20 |
this.mockDAB = this.mocker.registerMockComponent(DocumentAccessBridge.class); |
203 |
|
|
204 |
20 |
WikiDescriptorManager wikiDescriptorManager = this.mocker.registerMockComponent(WikiDescriptorManager.class); |
205 |
20 |
when(wikiDescriptorManager.getAllIds()).thenReturn( |
206 |
|
Arrays.asList(wikiReference1.getName(), wikiReference2.getName())); |
207 |
|
} |
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (86) |
Complexity: 1 |
Complexity Density: 0.01 |
|
209 |
20 |
@Before... |
210 |
|
public void setUp() throws Exception |
211 |
|
{ |
212 |
20 |
this.defaultSolrReferenceResolver = this.mocker.getInstance(SolrReferenceResolver.class); |
213 |
|
|
214 |
20 |
Utils.setComponentManager(this.mocker); |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
20 |
this.xwiki = mock(XWiki.class); |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
20 |
this.xcontext = new XWikiContext(); |
223 |
20 |
this.xcontext.setWikiId("xwiki"); |
224 |
20 |
this.xcontext.setWiki(this.xwiki); |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
20 |
Provider<XWikiContext> xcontextProvider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER); |
229 |
20 |
when(xcontextProvider.get()).thenReturn(this.xcontext); |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
20 |
Execution execution = this.mocker.getInstance(Execution.class); |
234 |
20 |
execution.setContext(new ExecutionContext()); |
235 |
20 |
execution.getContext().setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, this.xcontext); |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
20 |
this.objectReference1221 = new BaseObjectReference(this.classReference111, 0, this.documentReference122); |
240 |
20 |
this.objectReference1222 = new BaseObjectReference(this.classReference111, 1, this.documentReference122); |
241 |
20 |
this.propertyReference12221 = new ObjectPropertyReference("aStringProperty", objectReference1222); |
242 |
20 |
this.propertyReference12223 = new ObjectPropertyReference("anIntegerProperty", objectReference1222); |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
20 |
this.xclass111 = mock(BaseClass.class); |
247 |
20 |
this.xdocument111 = mock(XWikiDocument.class, "xwikiDocument111"); |
248 |
20 |
this.xdocument112 = mock(XWikiDocument.class, "xwikiDocument112"); |
249 |
20 |
this.xdocument113 = mock(XWikiDocument.class, "xwikiDocument113"); |
250 |
|
|
251 |
20 |
this.xdocument121 = mock(XWikiDocument.class, "xwikiDocument121"); |
252 |
20 |
this.xattachment1211 = mock(XWikiAttachment.class, "xwikiAttachment1211"); |
253 |
20 |
this.xattachment1212 = mock(XWikiAttachment.class, "xwikiAttachment1212"); |
254 |
|
|
255 |
20 |
this.xdocument122 = mock(XWikiDocument.class, "xwikiDocument122"); |
256 |
20 |
this.xobject1221 = mock(BaseObject.class, "xwikiObject1221"); |
257 |
20 |
this.xobject1222 = mock(BaseObject.class, "xwikiObject1222"); |
258 |
20 |
this.xproperty12221 = mock(StringProperty.class, "xwikiProperty12221"); |
259 |
20 |
this.xproperty12223 = mock(IntegerProperty.class, "xwikiProperty12223"); |
260 |
|
|
261 |
20 |
this.queryManager = this.mocker.getInstance(QueryManager.class); |
262 |
20 |
final Query spacesWiki1Query = mock(DefaultQuery.class, "getSpacesWiki1"); |
263 |
20 |
final Query documentsSpace11Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace11"); |
264 |
20 |
final Query documentsSpace12Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace12"); |
265 |
20 |
final Query documentsSpace13Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace13"); |
266 |
20 |
final Query spacesWiki2Query = mock(DefaultQuery.class, "getSpacesWiki2"); |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
20 |
when(xwiki.exists(any(DocumentReference.class), any(XWikiContext.class))).thenReturn(true); |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
20 |
when(queryManager.getNamedQuery("getSpaces")).thenReturn(spacesWiki1Query); |
275 |
|
|
276 |
20 |
when(spacesWiki1Query.setWiki(wikiReference1.getName())).thenReturn(spacesWiki1Query); |
277 |
|
|
278 |
20 |
when(spacesWiki1Query.setWiki(wikiReference2.getName())).thenReturn(spacesWiki2Query); |
279 |
|
|
280 |
20 |
when(queryManager.getNamedQuery("getSpaceDocsName")).thenReturn(documentsSpace11Query); |
281 |
|
|
282 |
20 |
when(documentsSpace11Query.setWiki(any(String.class))).thenReturn(documentsSpace11Query); |
283 |
|
|
284 |
20 |
EntityReferenceSerializer<String> localEntityReferenceSerializer = |
285 |
|
this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING, "local"); |
286 |
20 |
when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference11))) |
287 |
|
.thenReturn(documentsSpace11Query); |
288 |
20 |
when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference12))) |
289 |
|
.thenReturn(documentsSpace12Query); |
290 |
20 |
when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference13))) |
291 |
|
.thenReturn(documentsSpace13Query); |
292 |
|
|
293 |
|
|
294 |
20 |
when(spacesWiki1Query.execute()).thenReturn( |
295 |
|
Arrays.<Object>asList(localEntityReferenceSerializer.serialize(spaceReference11), |
296 |
|
localEntityReferenceSerializer.serialize(spaceReference12), |
297 |
|
localEntityReferenceSerializer.serialize(spaceReference13))); |
298 |
|
|
299 |
20 |
when(spacesWiki2Query.execute()).thenReturn(Collections.emptyList()); |
300 |
|
|
301 |
|
|
302 |
20 |
when(documentsSpace11Query.execute()).thenReturn( |
303 |
|
Arrays.<Object> asList(classReference111.getName(), documentReference112.getName(), |
304 |
|
documentReference113.getName())); |
305 |
|
|
306 |
|
|
307 |
20 |
when(xwiki.getDocument(eq(documentReference111), any(XWikiContext.class))).thenReturn(xdocument111); |
308 |
20 |
when(this.mockDAB.getDocument(documentReference111)).thenReturn(xdocument111); |
309 |
|
|
310 |
20 |
when(xdocument111.getXClass()).thenReturn(xclass111); |
311 |
|
|
312 |
|
|
313 |
20 |
when(xwiki.getDocument(eq(documentReference112), any(XWikiContext.class))).thenReturn(xdocument112); |
314 |
|
|
315 |
20 |
when(xdocument112.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap()); |
316 |
|
|
317 |
20 |
when(xdocument112.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList()); |
318 |
|
|
319 |
|
|
320 |
20 |
when(xwiki.getDocument(eq(documentReference113), any(XWikiContext.class))).thenReturn(xdocument113); |
321 |
|
|
322 |
20 |
when(xdocument113.getAttachmentList()).thenReturn(Collections.<XWikiAttachment>emptyList()); |
323 |
|
|
324 |
20 |
when(xdocument113.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap()); |
325 |
|
|
326 |
20 |
when(xdocument113.getTranslationLocales(any(XWikiContext.class))).thenReturn(Arrays.asList(new Locale("ro"))); |
327 |
|
|
328 |
|
|
329 |
20 |
when(documentsSpace12Query.execute()).thenReturn( |
330 |
|
Arrays.<Object> asList(documentReference121.getName(), documentReference122.getName())); |
331 |
|
|
332 |
|
|
333 |
20 |
when(xwiki.getDocument(eq(documentReference121), any(XWikiContext.class))).thenReturn(xdocument121); |
334 |
|
|
335 |
20 |
when(xdocument121.getAttachmentList()).thenReturn(Arrays.asList(xattachment1211, xattachment1212)); |
336 |
|
|
337 |
20 |
when(xattachment1211.getReference()).thenReturn(attachmentReference1211); |
338 |
|
|
339 |
20 |
when(xattachment1212.getReference()).thenReturn(attachmentReference1212); |
340 |
|
|
341 |
20 |
when(xdocument121.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap()); |
342 |
|
|
343 |
20 |
when(xdocument121.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList()); |
344 |
|
|
345 |
|
|
346 |
20 |
when(xwiki.getDocument(eq(documentReference122), any(XWikiContext.class))).thenReturn(xdocument122); |
347 |
|
|
348 |
20 |
when(xdocument122.getAttachmentList()).thenReturn(Collections.<XWikiAttachment>emptyList()); |
349 |
|
|
350 |
20 |
Map<DocumentReference, List<BaseObject>> xObjects = new HashMap<DocumentReference, List<BaseObject>>(); |
351 |
|
|
352 |
20 |
xObjects.put(classReference111, Arrays.asList(null, xobject1221, xobject1222)); |
353 |
20 |
when(xdocument122.getXObjects()).thenReturn(xObjects); |
354 |
|
|
355 |
20 |
when(xdocument122.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList()); |
356 |
|
|
357 |
|
|
358 |
20 |
when(xdocument122.getXObject(objectReference1221)).thenReturn(xobject1221); |
359 |
20 |
when(xdocument122.getXObject((EntityReference) objectReference1221)).thenReturn(xobject1221); |
360 |
|
|
361 |
20 |
when(xobject1221.getReference()).thenReturn(objectReference1221); |
362 |
|
|
363 |
20 |
when(xobject1221.getXClass(any(XWikiContext.class))).thenReturn(xclass111); |
364 |
|
|
365 |
20 |
when(xobject1221.getFieldList()).thenReturn(Collections.EMPTY_LIST); |
366 |
|
|
367 |
|
|
368 |
20 |
when(xdocument122.getXObject(objectReference1222)).thenReturn(xobject1222); |
369 |
20 |
when(xdocument122.getXObject((EntityReference) objectReference1222)).thenReturn(xobject1222); |
370 |
|
|
371 |
20 |
when(xobject1222.getReference()).thenReturn(objectReference1222); |
372 |
|
|
373 |
20 |
when(xobject1222.getXClass(any(XWikiContext.class))).thenReturn(xclass111); |
374 |
|
|
375 |
20 |
when(xobject1222.getFieldList()).thenReturn( |
376 |
|
Arrays.asList(xproperty12221, xproperty12223)); |
377 |
|
|
378 |
|
|
379 |
20 |
when(xproperty12221.getReference()).thenReturn(propertyReference12221); |
380 |
20 |
when(xproperty12221.getName()).thenReturn(propertyReference12221.getName()); |
381 |
|
|
382 |
20 |
when(xproperty12223.getReference()).thenReturn(propertyReference12223); |
383 |
20 |
when(xproperty12223.getName()).thenReturn(propertyReference12223.getName()); |
384 |
|
|
385 |
|
|
386 |
20 |
when(xclass111.get(propertyReference12221.getName())).thenReturn(null); |
387 |
|
|
388 |
20 |
when(xclass111.get(propertyReference12223.getName())).thenReturn(null); |
389 |
|
|
390 |
|
|
391 |
20 |
when(documentsSpace13Query.execute()).thenReturn(Collections.emptyList()); |
392 |
|
} |
393 |
|
|
394 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
395 |
1 |
@Test... |
396 |
|
public void getReferencesFarm() throws Exception |
397 |
|
{ |
398 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(null); |
399 |
|
|
400 |
1 |
Assert.assertNotNull(result); |
401 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(12)); |
402 |
|
|
403 |
1 |
assertThat( |
404 |
|
result, |
405 |
|
containsInAnyOrder(classReference111, documentReference112, documentReference113, documentReference113RO, |
406 |
|
documentReference121, attachmentReference1211, attachmentReference1212, documentReference122, |
407 |
|
objectReference1221, objectReference1222, propertyReference12221, propertyReference12223)); |
408 |
|
} |
409 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
410 |
1 |
@Test... |
411 |
|
public void getReferencesEmptyWiki() throws Exception |
412 |
|
{ |
413 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(wikiReference2); |
414 |
|
|
415 |
1 |
Assert.assertNotNull(result); |
416 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(0)); |
417 |
|
} |
418 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
419 |
1 |
@Test... |
420 |
|
public void getReferencesWiki() throws Exception |
421 |
|
{ |
422 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(wikiReference1); |
423 |
|
|
424 |
1 |
Assert.assertNotNull(result); |
425 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(12)); |
426 |
|
|
427 |
1 |
assertThat( |
428 |
|
result, |
429 |
|
containsInAnyOrder(classReference111, documentReference112, documentReference113, documentReference113RO, |
430 |
|
documentReference121, attachmentReference1211, attachmentReference1212, documentReference122, |
431 |
|
objectReference1221, objectReference1222, propertyReference12221, propertyReference12223)); |
432 |
|
} |
433 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
434 |
1 |
@Test... |
435 |
|
public void getReferencesSpaceReference() throws Exception |
436 |
|
{ |
437 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(spaceReference11); |
438 |
|
|
439 |
1 |
Assert.assertNotNull(result); |
440 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(4)); |
441 |
|
|
442 |
1 |
assertThat( |
443 |
|
result, |
444 |
|
containsInAnyOrder((EntityReference) classReference111, (EntityReference) documentReference112, |
445 |
|
(EntityReference) documentReference113, (EntityReference) documentReference113RO)); |
446 |
|
} |
447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
448 |
1 |
@Test... |
449 |
|
public void getReferencesEmptyDocument() throws Exception |
450 |
|
{ |
451 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference112); |
452 |
|
|
453 |
1 |
Assert.assertNotNull(result); |
454 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(1)); |
455 |
|
|
456 |
1 |
Assert.assertEquals(documentReference112, result.iterator().next()); |
457 |
|
} |
458 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
459 |
1 |
@Test... |
460 |
|
public void getReferencesTranslatedDocument() throws Exception |
461 |
|
{ |
462 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference113); |
463 |
|
|
464 |
1 |
Assert.assertNotNull(result); |
465 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(2)); |
466 |
|
|
467 |
1 |
assertThat(result, |
468 |
|
containsInAnyOrder((EntityReference) documentReference113, (EntityReference) documentReference113RO)); |
469 |
|
} |
470 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
471 |
1 |
@Test... |
472 |
|
public void getReferencesDocumentWithAttachments() throws Exception |
473 |
|
{ |
474 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference121); |
475 |
|
|
476 |
1 |
Assert.assertNotNull(result); |
477 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(3)); |
478 |
|
|
479 |
1 |
assertThat(result, containsInAnyOrder(documentReference121, attachmentReference1211, attachmentReference1212)); |
480 |
|
} |
481 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
482 |
1 |
@Test... |
483 |
|
public void getReferencesDocumentWithObjects() throws Exception |
484 |
|
{ |
485 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference122); |
486 |
|
|
487 |
1 |
Assert.assertNotNull(result); |
488 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(5)); |
489 |
|
|
490 |
1 |
assertThat( |
491 |
|
result, |
492 |
|
containsInAnyOrder(documentReference122, objectReference1221, propertyReference12221, |
493 |
|
propertyReference12223, objectReference1222)); |
494 |
|
} |
495 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
496 |
1 |
@Test... |
497 |
|
public void getReferencesAttachment() throws Exception |
498 |
|
{ |
499 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(attachmentReference1211); |
500 |
|
|
501 |
1 |
Assert.assertNotNull(result); |
502 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(1)); |
503 |
|
|
504 |
1 |
Assert.assertEquals(attachmentReference1211, result.iterator().next()); |
505 |
|
} |
506 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
507 |
1 |
@Test... |
508 |
|
public void getReferencesEmptyObject() throws Exception |
509 |
|
{ |
510 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(objectReference1221); |
511 |
|
|
512 |
1 |
Assert.assertNotNull(result); |
513 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(1)); |
514 |
|
|
515 |
1 |
Assert.assertEquals(objectReference1221, result.iterator().next()); |
516 |
|
} |
517 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
518 |
1 |
@Test... |
519 |
|
public void getReferencesObject() throws Exception |
520 |
|
{ |
521 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(objectReference1222); |
522 |
|
|
523 |
1 |
Assert.assertNotNull(result); |
524 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(3)); |
525 |
|
|
526 |
1 |
assertThat(result, containsInAnyOrder(objectReference1222, propertyReference12221, propertyReference12223)); |
527 |
|
} |
528 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
529 |
1 |
@Test... |
530 |
|
public void getReferencesProperty() throws Exception |
531 |
|
{ |
532 |
1 |
Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(propertyReference12221); |
533 |
|
|
534 |
1 |
Assert.assertNotNull(result); |
535 |
1 |
assertThat(result, Matchers.<EntityReference> iterableWithSize(1)); |
536 |
|
|
537 |
1 |
Assert.assertEquals(propertyReference12221, result.iterator().next()); |
538 |
|
} |
539 |
|
|
540 |
|
|
541 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
542 |
1 |
@Test... |
543 |
|
public void getIdLocaleInReference() throws Exception |
544 |
|
{ |
545 |
|
|
546 |
1 |
DocumentReference reference = new DocumentReference("wiki", "space", "name", new Locale("en")); |
547 |
|
|
548 |
|
|
549 |
1 |
String id = this.defaultSolrReferenceResolver.getId(reference); |
550 |
|
|
551 |
|
|
552 |
1 |
Assert.assertEquals("wiki:space.name_en", id); |
553 |
|
} |
554 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
555 |
1 |
@Test... |
556 |
|
public void getIdLocaleInDatabase() throws Exception |
557 |
|
{ |
558 |
1 |
when(xdocument111.getRealLocale()).thenReturn(Locale.FRENCH); |
559 |
|
|
560 |
|
|
561 |
1 |
String id = this.defaultSolrReferenceResolver.getId(this.documentReference111); |
562 |
|
|
563 |
|
|
564 |
1 |
Assert.assertEquals(this.documentReference111 + "_fr", id); |
565 |
|
} |
566 |
|
|
567 |
|
|
568 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
569 |
1 |
@Test... |
570 |
|
public void getQueryWiki() throws Exception |
571 |
|
{ |
572 |
1 |
Assert.assertEquals("wiki:wiki1", this.defaultSolrReferenceResolver.getQuery(wikiReference1)); |
573 |
|
} |
574 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
575 |
1 |
@Test... |
576 |
|
public void getQuerySpace() throws Exception |
577 |
|
{ |
578 |
1 |
Assert.assertEquals("wiki:wiki1 AND space_exact:space11.data", |
579 |
|
this.defaultSolrReferenceResolver.getQuery(spaceReference11)); |
580 |
|
} |
581 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
582 |
1 |
@Test... |
583 |
|
public void getQueryDocument() throws Exception |
584 |
|
{ |
585 |
1 |
Assert.assertEquals("wiki:wiki1 AND space_exact:space11.data AND name_exact:class111", |
586 |
|
this.defaultSolrReferenceResolver.getQuery(documentReference111)); |
587 |
|
} |
588 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
589 |
1 |
@Test... |
590 |
|
public void getQueryObject() throws Exception |
591 |
|
{ |
592 |
1 |
Assert.assertEquals("wiki:wiki1" + " AND space_exact:space12.code AND name_exact:document122" |
593 |
|
+ " AND class:space11.data.class111 AND number:0", |
594 |
|
this.defaultSolrReferenceResolver.getQuery(objectReference1221)); |
595 |
|
} |
596 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
597 |
1 |
@Test... |
598 |
|
public void getQueryObjectProperty() throws Exception |
599 |
|
{ |
600 |
1 |
Assert.assertEquals( |
601 |
|
"id:wiki1\\:space12.code.document122\\^wiki1\\:space11.data.class111\\[1\\].aStringProperty", |
602 |
|
this.defaultSolrReferenceResolver.getQuery(propertyReference12221)); |
603 |
|
} |
604 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
605 |
1 |
@Test... |
606 |
|
public void getQueryAttachment() throws Exception |
607 |
|
{ |
608 |
1 |
Assert.assertEquals("id:wiki1\\:space12.code.document121@attachment1211.ext", |
609 |
|
this.defaultSolrReferenceResolver.getQuery(attachmentReference1211)); |
610 |
|
} |
611 |
|
} |