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; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
|
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.context.internal.DefaultExecution; |
28 |
|
import org.xwiki.model.internal.DefaultModelConfiguration; |
29 |
|
import org.xwiki.model.internal.DefaultModelContext; |
30 |
|
import org.xwiki.model.internal.reference.DefaultEntityReferenceProvider; |
31 |
|
import org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer; |
32 |
|
import org.xwiki.model.internal.reference.RelativeStringEntityReferenceResolver; |
33 |
|
import org.xwiki.model.reference.WikiReference; |
34 |
|
import org.xwiki.search.solr.internal.api.SolrConfiguration; |
35 |
|
import org.xwiki.search.solr.internal.api.SolrIndexer; |
36 |
|
import org.xwiki.test.annotation.ComponentList; |
37 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
38 |
|
|
39 |
|
import com.xpn.xwiki.XWiki; |
40 |
|
import com.xpn.xwiki.XWikiContext; |
41 |
|
import com.xpn.xwiki.internal.model.reference.CompactWikiStringEntityReferenceSerializer; |
42 |
|
import com.xpn.xwiki.internal.model.reference.CurrentEntityReferenceProvider; |
43 |
|
import com.xpn.xwiki.internal.model.reference.CurrentMixedEntityReferenceProvider; |
44 |
|
import com.xpn.xwiki.internal.model.reference.CurrentMixedStringDocumentReferenceResolver; |
45 |
|
import com.xpn.xwiki.internal.model.reference.CurrentReferenceDocumentReferenceResolver; |
46 |
|
import com.xpn.xwiki.internal.model.reference.CurrentReferenceEntityReferenceResolver; |
47 |
|
import com.xpn.xwiki.web.Utils; |
48 |
|
|
49 |
|
import static org.mockito.ArgumentMatchers.any; |
50 |
|
import static org.mockito.ArgumentMatchers.eq; |
51 |
|
import static org.mockito.Mockito.mock; |
52 |
|
import static org.mockito.Mockito.when; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@version |
58 |
|
|
59 |
|
@ComponentList({DefaultModelContext.class, DefaultModelConfiguration.class, LocalStringEntityReferenceSerializer.class, |
60 |
|
RelativeStringEntityReferenceResolver.class, CurrentReferenceDocumentReferenceResolver.class, |
61 |
|
CurrentReferenceEntityReferenceResolver.class, CurrentEntityReferenceProvider.class, |
62 |
|
CurrentMixedStringDocumentReferenceResolver.class, CurrentMixedEntityReferenceProvider.class, |
63 |
|
DefaultEntityReferenceProvider.class, CompactWikiStringEntityReferenceSerializer.class, DefaultExecution.class}) |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
64 |
|
public class DefaultSolrIndexerTest |
65 |
|
{ |
66 |
|
@Rule |
67 |
|
public final MockitoComponentMockingRule<SolrIndexer> mocker = new MockitoComponentMockingRule<SolrIndexer>( |
68 |
|
DefaultSolrIndexer.class); |
69 |
|
|
70 |
|
private XWikiContext xcontext; |
71 |
|
|
72 |
|
private XWiki xwiki; |
73 |
|
|
74 |
|
private SolrConfiguration mockConfig; |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
76 |
1 |
@Before... |
77 |
|
public void configure() throws Exception |
78 |
|
{ |
79 |
1 |
Utils.setComponentManager(mocker); |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
1 |
this.xwiki = mock(XWiki.class); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
1 |
this.xcontext = new XWikiContext(); |
88 |
1 |
this.xcontext.setWikiId("xwiki"); |
89 |
1 |
this.xcontext.setWiki(this.xwiki); |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
1 |
URL url = this.getClass().getClassLoader().getResource("solrhome"); |
94 |
1 |
this.mockConfig = this.mocker.getInstance(SolrConfiguration.class); |
95 |
1 |
when(this.mockConfig.getInstanceConfiguration(eq(EmbeddedSolrInstance.TYPE), eq("home"), any())) |
96 |
|
.thenReturn(url.getPath()); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
99 |
1 |
@Test... |
100 |
|
public void testIndexEmptyWiki() throws Exception |
101 |
|
{ |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
1 |
WikiReference wikiReference = new WikiReference("xwiki"); |
107 |
|
|
108 |
|
|
109 |
|
} |
110 |
|
} |