View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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.apache.maven.index.expr.UserInputSearchExpression;
28  import org.junit.Test;
29  
30  import static org.hamcrest.CoreMatchers.is;
31  import static org.junit.Assert.assertEquals;
32  import static org.junit.Assert.assertThat;
33  
34  public class Mindexer35NexusIndexerTest extends AbstractNexusIndexerTest {
35      protected File repo = new File(getBasedir(), "src/test/mindexer-35");
36  
37      @Override
38      protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
39          context = nexusIndexer.addIndexingContext(
40                  "mindexer-35", "mindexer-35", repo, indexDir, null, null, FULL_CREATORS);
41          nexusIndexer.scan(context);
42      }
43  
44      @Test
45      public void testSearchWar() throws Exception {
46          Query q = nexusIndexer.constructQuery(MAVEN.CLASSNAMES, new UserInputSearchExpression("WebappClass"));
47  
48          FlatSearchResponse response = nexusIndexer.searchFlat(new FlatSearchRequest(q));
49  
50          Collection<ArtifactInfo> r = response.getResults();
51  
52          assertThat(r.size(), is(1));
53  
54          List<ArtifactInfo> list = new ArrayList<>(r);
55  
56          ArtifactInfo ai;
57  
58          // g a v p c #1
59          ai = list.get(0);
60  
61          assertEquals("org.apache.maven.indexer.test", ai.getGroupId());
62          assertEquals("sample-war", ai.getArtifactId());
63          assertEquals("1.0-SNAPSHOT", ai.getVersion());
64          assertEquals("war", ai.getPackaging());
65          assertEquals(null, ai.getClassifier());
66          assertEquals("mindexer-35", ai.getRepository());
67          assertEquals("war", ai.getFileExtension());
68      }
69  }