1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.index;
20
21 import java.io.File;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.List;
25
26 import org.apache.lucene.search.Query;
27 import org.junit.Test;
28
29 import static org.junit.Assert.assertEquals;
30 import static org.junit.Assert.assertNull;
31
32 public class Nexus2046NexusIndexerTest extends AbstractNexusIndexerTest {
33 protected File repo = new File(getBasedir(), "src/test/nexus-2046");
34
35 @Override
36 protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
37 context = nexusIndexer.addIndexingContext(
38 "nexus-2046", "nexus-2046", repo, indexDir, null, null, DEFAULT_CREATORS);
39 nexusIndexer.scan(context);
40 }
41
42 @Test
43 public void testSearchFlat() throws Exception {
44
45
46 Query q = nexusIndexer.constructQuery(MAVEN.GROUP_ID, "org.maven.ide", SearchType.SCORED);
47 FlatSearchResponse response = nexusIndexer.searchFlat(new FlatSearchRequest(q));
48 Collection<ArtifactInfo> r = response.getResults();
49
50 assertEquals(1, r.size());
51
52 List<ArtifactInfo> list = new ArrayList<>(r);
53
54 ArtifactInfo ai;
55
56
57 ai = list.get(0);
58
59 assertEquals("org.maven.ide.eclipse", ai.getGroupId());
60 assertEquals("org.maven.ide.eclipse.feature", ai.getArtifactId());
61 assertEquals("0.9.7", ai.getVersion());
62 assertEquals("eclipse-feature", ai.getPackaging());
63 assertNull(ai.getClassifier());
64 assertEquals("nexus-2046", ai.getRepository());
65 assertEquals("jar", ai.getFileExtension());
66 }
67 }