1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.search.solr.internal.reference

File SolrReferenceResolverTest.java

 

Code metrics

0
148
22
1
577
370
22
0.15
6.73
22
1

Classes

Class Line # Actions
SolrReferenceResolverTest 90 148 0% 22 0
1.0100%
 

Contributing tests

This file is covered by 20 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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.reference.AttachmentReference;
41    import org.xwiki.model.reference.DocumentReference;
42    import org.xwiki.model.reference.EntityReference;
43    import org.xwiki.model.reference.EntityReferenceSerializer;
44    import org.xwiki.model.reference.ObjectPropertyReference;
45    import org.xwiki.model.reference.SpaceReference;
46    import org.xwiki.model.reference.WikiReference;
47    import org.xwiki.query.Query;
48    import org.xwiki.query.QueryManager;
49    import org.xwiki.query.internal.DefaultQuery;
50    import org.xwiki.test.annotation.BeforeComponent;
51    import org.xwiki.test.annotation.ComponentList;
52    import org.xwiki.test.mockito.MockitoComponentManagerRule;
53    import org.xwiki.wiki.descriptor.WikiDescriptorManager;
54   
55    import com.xpn.xwiki.XWiki;
56    import com.xpn.xwiki.XWikiContext;
57    import com.xpn.xwiki.doc.XWikiAttachment;
58    import com.xpn.xwiki.doc.XWikiDocument;
59    import com.xpn.xwiki.objects.BaseObject;
60    import com.xpn.xwiki.objects.BaseObjectReference;
61    import com.xpn.xwiki.objects.IntegerProperty;
62    import com.xpn.xwiki.objects.StringProperty;
63    import com.xpn.xwiki.objects.classes.BaseClass;
64    import com.xpn.xwiki.test.reference.ReferenceComponentList;
65    import com.xpn.xwiki.web.Utils;
66   
67    import static org.hamcrest.MatcherAssert.assertThat;
68    import static org.hamcrest.Matchers.containsInAnyOrder;
69    import static org.mockito.ArgumentMatchers.any;
70    import static org.mockito.ArgumentMatchers.eq;
71    import static org.mockito.Mockito.mock;
72    import static org.mockito.Mockito.when;
73   
74    /**
75    * Tests for the extraction of indexable references from a start reference.
76    *
77    * @version $Id: c3b97fd1679798e22f492924849b9c75a8536f5b $
78    */
79    @ComponentList({
80    DefaultExecution.class,
81    AttachmentSolrReferenceResolver.class,
82    DefaultSolrReferenceResolver.class,
83    DocumentSolrReferenceResolver.class,
84    ObjectPropertySolrReferenceResolver.class,
85    ObjectSolrReferenceResolver.class,
86    SpaceSolrReferenceResolver.class,
87    WikiSolrReferenceResolver.class,
88    })
89    @ReferenceComponentList
 
90    public class SolrReferenceResolverTest
91    {
92    @Rule
93    public final MockitoComponentManagerRule mocker = new MockitoComponentManagerRule();
94   
95    private SolrReferenceResolver defaultSolrReferenceResolver;
96   
97    private XWikiContext xcontext;
98   
99    private XWiki xwiki;
100   
101    private WikiReference wikiReference1 = new WikiReference("wiki1");
102   
103    private SpaceReference spaceReference11 = new SpaceReference("data", new SpaceReference("space11", wikiReference1));
104   
105    private DocumentReference classReference111 = new DocumentReference("class111", spaceReference11);
106   
107    private DocumentReference documentReference111 = classReference111;
108   
109    private BaseClass xclass111;
110   
111    private XWikiDocument xdocument111;
112   
113    private DocumentReference documentReference112 = new DocumentReference("document112", spaceReference11);
114   
115    private XWikiDocument xdocument112;
116   
117    private DocumentReference documentReference113 = new DocumentReference("document113", spaceReference11);
118   
119    private DocumentReference documentReference113RO = new DocumentReference(documentReference113, new Locale("ro"));
120   
121    private XWikiDocument xdocument113 = null;
122   
123    private SpaceReference spaceReference12 = new SpaceReference("code", new SpaceReference("space12", wikiReference1));
124   
125    private DocumentReference documentReference121 = new DocumentReference("document121", spaceReference12);
126   
127    private AttachmentReference attachmentReference1211 = new AttachmentReference("attachment1211.ext",
128    documentReference121);
129   
130    private XWikiAttachment xattachment1211;
131   
132    private AttachmentReference attachmentReference1212 = new AttachmentReference("attachment1212.ext",
133    documentReference121);
134   
135    private XWikiAttachment xattachment1212;
136   
137    private XWikiDocument xdocument121;
138   
139    private DocumentReference documentReference122 = new DocumentReference("document122", spaceReference12);
140   
141    private BaseObjectReference objectReference1221;
142   
143    private BaseObject xobject1221;
144   
145    private BaseObjectReference objectReference1222;
146   
147    private ObjectPropertyReference propertyReference12221;
148   
149    private StringProperty xproperty12221;
150   
151    private ObjectPropertyReference propertyReference12223;
152   
153    private IntegerProperty xproperty12223;
154   
155    private BaseObject xobject1222;
156   
157    private XWikiDocument xdocument122;
158   
159    private SpaceReference spaceReference13 = new SpaceReference("test", new SpaceReference("space13", wikiReference1));
160   
161    private WikiReference wikiReference2 = new WikiReference("wiki2");
162   
163    private QueryManager queryManager;
164   
 
165  20 toggle @BeforeComponent
166    public void registerComponents() throws Exception
167    {
168  20 this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
169  20 this.mocker.registerMockComponent(QueryManager.class);
170   
171  20 WikiDescriptorManager wikiDescriptorManager = this.mocker.registerMockComponent(WikiDescriptorManager.class);
172  20 when(wikiDescriptorManager.getAllIds()).thenReturn(
173    Arrays.asList(wikiReference1.getName(), wikiReference2.getName()));
174    }
175   
 
176  20 toggle @Before
177    public void setUp() throws Exception
178    {
179  20 this.defaultSolrReferenceResolver = this.mocker.getInstance(SolrReferenceResolver.class);
180   
181  20 Utils.setComponentManager(this.mocker);
182   
183    // XWiki
184   
185  20 this.xwiki = mock(XWiki.class);
186   
187    // XWikiContext
188   
189  20 this.xcontext = new XWikiContext();
190  20 this.xcontext.setWikiId("xwiki");
191  20 this.xcontext.setWiki(this.xwiki);
192   
193    // XWikiContext Provider
194   
195  20 Provider<XWikiContext> xcontextProvider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER);
196  20 when(xcontextProvider.get()).thenReturn(this.xcontext);
197   
198    // XWikiContext trough Execution
199   
200  20 Execution execution = this.mocker.getInstance(Execution.class);
201  20 execution.setContext(new ExecutionContext());
202  20 execution.getContext().setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, this.xcontext);
203   
204    // References
205   
206  20 this.objectReference1221 = new BaseObjectReference(this.classReference111, 0, this.documentReference122);
207  20 this.objectReference1222 = new BaseObjectReference(this.classReference111, 1, this.documentReference122);
208  20 this.propertyReference12221 = new ObjectPropertyReference("aStringProperty", objectReference1222);
209  20 this.propertyReference12223 = new ObjectPropertyReference("anIntegerProperty", objectReference1222);
210   
211    // XWiki model data
212   
213  20 this.xclass111 = mock(BaseClass.class);
214  20 this.xdocument111 = mock(XWikiDocument.class, "xwikiDocument111");
215  20 this.xdocument112 = mock(XWikiDocument.class, "xwikiDocument112");
216  20 this.xdocument113 = mock(XWikiDocument.class, "xwikiDocument113");
217   
218  20 this.xdocument121 = mock(XWikiDocument.class, "xwikiDocument121");
219  20 this.xattachment1211 = mock(XWikiAttachment.class, "xwikiAttachment1211");
220  20 this.xattachment1212 = mock(XWikiAttachment.class, "xwikiAttachment1212");
221   
222  20 this.xdocument122 = mock(XWikiDocument.class, "xwikiDocument122");
223  20 this.xobject1221 = mock(BaseObject.class, "xwikiObject1221");
224  20 this.xobject1222 = mock(BaseObject.class, "xwikiObject1222");
225  20 this.xproperty12221 = mock(StringProperty.class, "xwikiProperty12221");
226  20 this.xproperty12223 = mock(IntegerProperty.class, "xwikiProperty12223");
227   
228  20 this.queryManager = this.mocker.getInstance(QueryManager.class);
229  20 final Query spacesWiki1Query = mock(DefaultQuery.class, "getSpacesWiki1");
230  20 final Query documentsSpace11Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace11");
231  20 final Query documentsSpace12Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace12");
232  20 final Query documentsSpace13Query = mock(DefaultQuery.class, "getSpaceDocsNameSpace13");
233  20 final Query spacesWiki2Query = mock(DefaultQuery.class, "getSpacesWiki2");
234   
235    // Data
236   
237  20 when(xwiki.exists(any(DocumentReference.class), any(XWikiContext.class))).thenReturn(true);
238   
239    // Query manager and specific queries mocking.
240   
241  20 when(queryManager.getNamedQuery("getSpaces")).thenReturn(spacesWiki1Query);
242   
243  20 when(spacesWiki1Query.setWiki(wikiReference1.getName())).thenReturn(spacesWiki1Query);
244   
245  20 when(spacesWiki1Query.setWiki(wikiReference2.getName())).thenReturn(spacesWiki2Query);
246   
247  20 when(queryManager.getNamedQuery("getSpaceDocsName")).thenReturn(documentsSpace11Query);
248   
249  20 when(documentsSpace11Query.setWiki(any(String.class))).thenReturn(documentsSpace11Query);
250   
251  20 EntityReferenceSerializer<String> localEntityReferenceSerializer =
252    this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING, "local");
253  20 when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference11)))
254    .thenReturn(documentsSpace11Query);
255  20 when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference12)))
256    .thenReturn(documentsSpace12Query);
257  20 when(documentsSpace11Query.bindValue("space", localEntityReferenceSerializer.serialize(spaceReference13)))
258    .thenReturn(documentsSpace13Query);
259   
260    // Spaces in wikis.
261  20 when(spacesWiki1Query.execute()).thenReturn(
262    Arrays.<Object>asList(localEntityReferenceSerializer.serialize(spaceReference11),
263    localEntityReferenceSerializer.serialize(spaceReference12),
264    localEntityReferenceSerializer.serialize(spaceReference13)));
265   
266  20 when(spacesWiki2Query.execute()).thenReturn(Collections.emptyList());
267   
268    // space 11
269  20 when(documentsSpace11Query.execute()).thenReturn(
270    Arrays.<Object> asList(classReference111.getName(), documentReference112.getName(),
271    documentReference113.getName()));
272   
273    // document 111
274  20 when(xwiki.getDocument(eq(documentReference111), any(XWikiContext.class))).thenReturn(xdocument111);
275   
276  20 when(xdocument111.getXClass()).thenReturn(xclass111);
277   
278    // document 112
279  20 when(xwiki.getDocument(eq(documentReference112), any(XWikiContext.class))).thenReturn(xdocument112);
280   
281  20 when(xdocument112.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap());
282   
283  20 when(xdocument112.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList());
284   
285    // document 113
286  20 when(xwiki.getDocument(eq(documentReference113), any(XWikiContext.class))).thenReturn(xdocument113);
287   
288  20 when(xdocument113.getAttachmentList()).thenReturn(Collections.<XWikiAttachment>emptyList());
289   
290  20 when(xdocument113.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap());
291   
292  20 when(xdocument113.getTranslationLocales(any(XWikiContext.class))).thenReturn(Arrays.asList(new Locale("ro")));
293   
294    // space 12
295  20 when(documentsSpace12Query.execute()).thenReturn(
296    Arrays.<Object> asList(documentReference121.getName(), documentReference122.getName()));
297   
298    // document 121
299  20 when(xwiki.getDocument(eq(documentReference121), any(XWikiContext.class))).thenReturn(xdocument121);
300   
301  20 when(xdocument121.getAttachmentList()).thenReturn(Arrays.asList(xattachment1211, xattachment1212));
302   
303  20 when(xattachment1211.getReference()).thenReturn(attachmentReference1211);
304   
305  20 when(xattachment1212.getReference()).thenReturn(attachmentReference1212);
306   
307  20 when(xdocument121.getXObjects()).thenReturn(Collections.<DocumentReference, List<BaseObject>>emptyMap());
308   
309  20 when(xdocument121.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList());
310   
311    // document 122
312  20 when(xwiki.getDocument(eq(documentReference122), any(XWikiContext.class))).thenReturn(xdocument122);
313   
314  20 when(xdocument122.getAttachmentList()).thenReturn(Collections.<XWikiAttachment>emptyList());
315   
316  20 Map<DocumentReference, List<BaseObject>> xObjects = new HashMap<DocumentReference, List<BaseObject>>();
317    // Yes, it seems that we can have null objects for some reason.
318  20 xObjects.put(classReference111, Arrays.asList(null, xobject1221, xobject1222));
319  20 when(xdocument122.getXObjects()).thenReturn(xObjects);
320   
321  20 when(xdocument122.getTranslationLocales(any(XWikiContext.class))).thenReturn(Collections.<Locale>emptyList());
322   
323    // object 1221
324  20 when(xdocument122.getXObject(objectReference1221)).thenReturn(xobject1221);
325  20 when(xdocument122.getXObject((EntityReference) objectReference1221)).thenReturn(xobject1221);
326   
327  20 when(xobject1221.getReference()).thenReturn(objectReference1221);
328   
329  20 when(xobject1221.getXClass(any(XWikiContext.class))).thenReturn(xclass111);
330   
331  20 when(xobject1221.getFieldList()).thenReturn(Collections.EMPTY_LIST);
332   
333    // object 1222
334  20 when(xdocument122.getXObject(objectReference1222)).thenReturn(xobject1222);
335  20 when(xdocument122.getXObject((EntityReference) objectReference1222)).thenReturn(xobject1222);
336   
337  20 when(xobject1222.getReference()).thenReturn(objectReference1222);
338   
339  20 when(xobject1222.getXClass(any(XWikiContext.class))).thenReturn(xclass111);
340   
341  20 when(xobject1222.getFieldList()).thenReturn(
342    Arrays.asList(xproperty12221, xproperty12223));
343   
344    // object 1222 fields
345  20 when(xproperty12221.getReference()).thenReturn(propertyReference12221);
346  20 when(xproperty12221.getName()).thenReturn(propertyReference12221.getName());
347   
348  20 when(xproperty12223.getReference()).thenReturn(propertyReference12223);
349  20 when(xproperty12223.getName()).thenReturn(propertyReference12223.getName());
350   
351    // class 111 fields
352  20 when(xclass111.get(propertyReference12221.getName())).thenReturn(null);
353   
354  20 when(xclass111.get(propertyReference12223.getName())).thenReturn(null);
355   
356    // space 13
357  20 when(documentsSpace13Query.execute()).thenReturn(Collections.emptyList());
358    }
359   
360    // getReferences
 
361  1 toggle @Test
362    public void getReferencesFarm() throws Exception
363    {
364  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(null);
365   
366  1 Assert.assertNotNull(result);
367  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(12));
368   
369  1 assertThat(
370    result,
371    containsInAnyOrder(classReference111, documentReference112, documentReference113, documentReference113RO,
372    documentReference121, attachmentReference1211, attachmentReference1212, documentReference122,
373    objectReference1221, objectReference1222, propertyReference12221, propertyReference12223));
374    }
375   
 
376  1 toggle @Test
377    public void getReferencesEmptyWiki() throws Exception
378    {
379  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(wikiReference2);
380   
381  1 Assert.assertNotNull(result);
382  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(0));
383    }
384   
 
385  1 toggle @Test
386    public void getReferencesWiki() throws Exception
387    {
388  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(wikiReference1);
389   
390  1 Assert.assertNotNull(result);
391  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(12));
392   
393  1 assertThat(
394    result,
395    containsInAnyOrder(classReference111, documentReference112, documentReference113, documentReference113RO,
396    documentReference121, attachmentReference1211, attachmentReference1212, documentReference122,
397    objectReference1221, objectReference1222, propertyReference12221, propertyReference12223));
398    }
399   
 
400  1 toggle @Test
401    public void getReferencesSpaceReference() throws Exception
402    {
403  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(spaceReference11);
404   
405  1 Assert.assertNotNull(result);
406  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(4));
407   
408  1 assertThat(
409    result,
410    containsInAnyOrder((EntityReference) classReference111, (EntityReference) documentReference112,
411    (EntityReference) documentReference113, (EntityReference) documentReference113RO));
412    }
413   
 
414  1 toggle @Test
415    public void getReferencesEmptyDocument() throws Exception
416    {
417  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference112);
418   
419  1 Assert.assertNotNull(result);
420  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(1));
421   
422  1 Assert.assertEquals(documentReference112, result.iterator().next());
423    }
424   
 
425  1 toggle @Test
426    public void getReferencesTranslatedDocument() throws Exception
427    {
428  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference113);
429   
430  1 Assert.assertNotNull(result);
431  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(2));
432   
433  1 assertThat(result,
434    containsInAnyOrder((EntityReference) documentReference113, (EntityReference) documentReference113RO));
435    }
436   
 
437  1 toggle @Test
438    public void getReferencesDocumentWithAttachments() throws Exception
439    {
440  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference121);
441   
442  1 Assert.assertNotNull(result);
443  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(3));
444   
445  1 assertThat(result, containsInAnyOrder(documentReference121, attachmentReference1211, attachmentReference1212));
446    }
447   
 
448  1 toggle @Test
449    public void getReferencesDocumentWithObjects() throws Exception
450    {
451  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(documentReference122);
452   
453  1 Assert.assertNotNull(result);
454  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(5));
455   
456  1 assertThat(
457    result,
458    containsInAnyOrder(documentReference122, objectReference1221, propertyReference12221,
459    propertyReference12223, objectReference1222));
460    }
461   
 
462  1 toggle @Test
463    public void getReferencesAttachment() throws Exception
464    {
465  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(attachmentReference1211);
466   
467  1 Assert.assertNotNull(result);
468  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(1));
469   
470  1 Assert.assertEquals(attachmentReference1211, result.iterator().next());
471    }
472   
 
473  1 toggle @Test
474    public void getReferencesEmptyObject() throws Exception
475    {
476  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(objectReference1221);
477   
478  1 Assert.assertNotNull(result);
479  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(1));
480   
481  1 Assert.assertEquals(objectReference1221, result.iterator().next());
482    }
483   
 
484  1 toggle @Test
485    public void getReferencesObject() throws Exception
486    {
487  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(objectReference1222);
488   
489  1 Assert.assertNotNull(result);
490  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(3));
491   
492  1 assertThat(result, containsInAnyOrder(objectReference1222, propertyReference12221, propertyReference12223));
493    }
494   
 
495  1 toggle @Test
496    public void getReferencesProperty() throws Exception
497    {
498  1 Iterable<EntityReference> result = this.defaultSolrReferenceResolver.getReferences(propertyReference12221);
499   
500  1 Assert.assertNotNull(result);
501  1 assertThat(result, Matchers.<EntityReference> iterableWithSize(1));
502   
503  1 Assert.assertEquals(propertyReference12221, result.iterator().next());
504    }
505   
506    // getId
507   
 
508  1 toggle @Test
509    public void getIdLocaleInReference() throws Exception
510    {
511    // Locale provided in the reference
512  1 DocumentReference reference = new DocumentReference("wiki", "space", "name", new Locale("en"));
513   
514    // Call
515  1 String id = this.defaultSolrReferenceResolver.getId(reference);
516   
517    // Assert
518  1 Assert.assertEquals("wiki:space.name_en", id);
519    }
520   
 
521  1 toggle @Test
522    public void getIdLocaleInDatabase() throws Exception
523    {
524  1 when(xdocument111.getRealLocale()).thenReturn(Locale.FRENCH);
525   
526    // Call
527  1 String id = this.defaultSolrReferenceResolver.getId(this.documentReference111);
528   
529    // Assert and verify
530  1 Assert.assertEquals(this.documentReference111 + "_fr", id);
531    }
532   
533    // getQuery
534   
 
535  1 toggle @Test
536    public void getQueryWiki() throws Exception
537    {
538  1 Assert.assertEquals("wiki:wiki1", this.defaultSolrReferenceResolver.getQuery(wikiReference1));
539    }
540   
 
541  1 toggle @Test
542    public void getQuerySpace() throws Exception
543    {
544  1 Assert.assertEquals("wiki:wiki1 AND space_exact:space11.data",
545    this.defaultSolrReferenceResolver.getQuery(spaceReference11));
546    }
547   
 
548  1 toggle @Test
549    public void getQueryDocument() throws Exception
550    {
551  1 Assert.assertEquals("wiki:wiki1 AND space_exact:space11.data AND name_exact:class111",
552    this.defaultSolrReferenceResolver.getQuery(documentReference111));
553    }
554   
 
555  1 toggle @Test
556    public void getQueryObject() throws Exception
557    {
558  1 Assert.assertEquals("wiki:wiki1" + " AND space_exact:space12.code AND name_exact:document122"
559    + " AND class:space11.data.class111 AND number:0",
560    this.defaultSolrReferenceResolver.getQuery(objectReference1221));
561    }
562   
 
563  1 toggle @Test
564    public void getQueryObjectProperty() throws Exception
565    {
566  1 Assert.assertEquals(
567    "id:wiki1\\:space12.code.document122\\^space11.data.class111\\[1\\].aStringProperty",
568    this.defaultSolrReferenceResolver.getQuery(propertyReference12221));
569    }
570   
 
571  1 toggle @Test
572    public void getQueryAttachment() throws Exception
573    {
574  1 Assert.assertEquals("id:wiki1\\:space12.code.document121@attachment1211.ext",
575    this.defaultSolrReferenceResolver.getQuery(attachmentReference1211));
576    }
577    }