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.junit.Test; 28 29 import static org.junit.Assert.assertEquals; 30 31 /** http://issues.sonatype.org/browse/NEXUS-13 */ 32 public class Nexus645NexusIndexerTest extends AbstractNexusIndexerTest { 33 protected File repo = new File(getBasedir(), "src/test/nexus-645"); 34 35 @Override 36 protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception { 37 context = 38 nexusIndexer.addIndexingContext("nexus-645", "nexus-645", repo, indexDir, null, null, DEFAULT_CREATORS); 39 nexusIndexer.scan(context); 40 } 41 42 @Test 43 public void testSearchFlat() throws Exception { 44 Query q = nexusIndexer.constructQuery(MAVEN.GROUP_ID, "org.codehaus.tycho", SearchType.SCORED); 45 FlatSearchResponse response = nexusIndexer.searchFlat(new FlatSearchRequest(q)); 46 Collection<ArtifactInfo> r = response.getResults(); 47 48 assertEquals(3, r.size()); 49 50 List<ArtifactInfo> list = new ArrayList<>(r); 51 52 ArtifactInfo ai; 53 54 // g a v p c #1 55 ai = list.get(0); 56 57 assertEquals("org.codehaus.tycho", ai.getGroupId()); 58 assertEquals("tycho-distribution", ai.getArtifactId()); 59 assertEquals("0.3.0-SNAPSHOT", ai.getVersion()); 60 assertEquals("pom", ai.getPackaging()); 61 assertEquals(null, ai.getClassifier()); 62 assertEquals("nexus-645", ai.getRepository()); 63 assertEquals("pom", ai.getFileExtension()); 64 65 // g a v p c #2 66 ai = list.get(1); 67 68 assertEquals("org.codehaus.tycho", ai.getGroupId()); 69 assertEquals("tycho-distribution", ai.getArtifactId()); 70 assertEquals("0.3.0-SNAPSHOT", ai.getVersion()); 71 assertEquals("tar.gz", ai.getPackaging()); 72 assertEquals("bin", ai.getClassifier()); 73 assertEquals("nexus-645", ai.getRepository()); 74 assertEquals("tar.gz", ai.getFileExtension()); 75 76 // g a v p c #3 77 ai = list.get(2); 78 79 assertEquals("org.codehaus.tycho", ai.getGroupId()); 80 assertEquals("tycho-distribution", ai.getArtifactId()); 81 assertEquals("0.3.0-SNAPSHOT", ai.getVersion()); 82 assertEquals("zip", ai.getPackaging()); 83 assertEquals("bin", ai.getClassifier()); 84 assertEquals("nexus-645", ai.getRepository()); 85 assertEquals("zip", ai.getFileExtension()); 86 } 87 }