use of org.apache.archiva.indexer.search.SearchResultHit in project archiva by apache.
the class MavenRepositorySearchTest method testQuickSearchMultipleArtifactsSameVersion.
@Test
public void testQuickSearchMultipleArtifactsSameVersion() throws Exception {
createIndexContainingMultipleArtifactsSameVersion(false);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
// search artifactId
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", selectedRepos, "archiva-search", null, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals(3, results.getTotalHits());
SearchResultHit hit = results.getHits().get(0);
assertEquals("org.apache.archiva", hit.getGroupId());
assertEquals("archiva-search", hit.getArtifactId());
assertEquals("1.0", hit.getVersions().get(0));
// only 1 version of 1.0 is retrieved
assertEquals(1, hit.getVersions().size());
}
use of org.apache.archiva.indexer.search.SearchResultHit in project archiva by apache.
the class MavenRepositorySearchTest method testArtifactFoundInMultipleRepositories.
@Test
public void testArtifactFoundInMultipleRepositories() throws Exception {
createSimpleIndex(true);
List<Path> files = new ArrayList<>();
files.add(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/repos/" + TEST_REPO_2 + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar"));
files.add(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/repos/" + TEST_REPO_2 + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar"));
createIndex(TEST_REPO_2, files, false);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
selectedRepos.add(TEST_REPO_2);
config.addManagedRepository(createRepositoryConfig(TEST_REPO_2));
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
// wait lucene flush.....
Thread.sleep(2000);
SearchResults results = search.search("user", selectedRepos, "archiva-search", null, null);
archivaConfigControl.verify();
assertNotNull(results);
SearchResultHit hit = results.getSearchResultHit(SearchUtil.getHitId("org.apache.archiva", "archiva-search", null, "jar"));
assertNotNull(hit);
assertEquals("org.apache.archiva", hit.getGroupId());
assertEquals("archiva-search", hit.getArtifactId());
assertEquals("not 2 version for hit " + hit + "::" + niceDisplay(results), 2, hit.getVersions().size());
assertTrue(hit.getVersions().contains("1.0"));
assertTrue(hit.getVersions().contains("1.1"));
archivaConfigControl.reset();
// TODO: [BROWSE] in artifact info from browse, display all the repositories where the artifact is found
}
use of org.apache.archiva.indexer.search.SearchResultHit in project archiva by apache.
the class MavenRepositorySearchTest method testSearchWithinSearchResults.
@Test
public void testSearchWithinSearchResults() throws Exception {
createSimpleIndex(true);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
List<String> previousSearchTerms = new ArrayList<>();
previousSearchTerms.add("archiva-test");
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", selectedRepos, "1.0", null, previousSearchTerms);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals("total hints not 1", 1, results.getTotalHits());
SearchResultHit hit = results.getHits().get(0);
assertEquals("org.apache.archiva", hit.getGroupId());
assertEquals("archiva-test", hit.getArtifactId());
assertEquals("versions not 1", 1, hit.getVersions().size());
assertEquals("1.0", hit.getVersions().get(0));
}
use of org.apache.archiva.indexer.search.SearchResultHit in project archiva by apache.
the class MavenRepositorySearchPaginateTest method build.
SearchResults build(int number, SearchResultLimits limits) {
SearchResults searchResults = new SearchResults();
searchResults.setLimits(limits);
for (int i = 0; i < number; i++) {
SearchResultHit hit = new SearchResultHit();
hit.setGroupId("commons-foo");
hit.setArtifactId("commons-bar-" + i);
hit.setPackaging("jar");
hit.setVersions(Arrays.asList("1.0"));
String id = SearchUtil.getHitId(hit.getGroupId(), hit.getArtifactId(), hit.getClassifier(), hit.getPackaging());
searchResults.addHit(id, hit);
}
searchResults.setTotalHits(number);
return searchResults;
}
Aggregations