use of org.apache.archiva.indexer.search.SearchResults in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchArtifactIdHasNumericChar.
// MRM-981 - artifactIds with numeric characters aren't found in advanced search
@Test
public void testAdvancedSearchArtifactIdHasNumericChar() throws Exception {
List<Path> files = new ArrayList<>();
files.add(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/repos/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar"));
files.add(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/repos/" + TEST_REPO_1 + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar"));
createIndex(TEST_REPO_1, files, true);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setArtifactId("artifactid-numeric");
searchFields.setRepositories(selectedRepos);
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals(2, results.getTotalHits());
}
use of org.apache.archiva.indexer.search.SearchResults in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchWithIncorrectPackaging.
@Test
public void testAdvancedSearchWithIncorrectPackaging() throws Exception {
createSimpleIndex(true);
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setGroupId("org.apache.archiva");
searchFields.setArtifactId("archiva-test");
searchFields.setVersion("2.0");
searchFields.setPackaging("war");
searchFields.setRepositories(selectedRepos);
EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
archivaConfigControl.replay();
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals(0, results.getTotalHits());
}
use of org.apache.archiva.indexer.search.SearchResults 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;
}
use of org.apache.archiva.indexer.search.SearchResults in project archiva by apache.
the class MavenRepositorySearchPaginateTest method paginatedResult.
@Test
public void paginatedResult() throws Exception {
MavenRepositorySearch search = new MavenRepositorySearch();
SearchResults searchResults = build(32, new SearchResultLimits(1));
searchResults = search.paginate(searchResults);
assertEquals(2, searchResults.getReturnedHitsCount());
}
use of org.apache.archiva.indexer.search.SearchResults in project archiva by apache.
the class MavenRepositorySearchPaginateTest method nonPaginatedHugeResult.
@Test
public void nonPaginatedHugeResult() throws Exception {
MavenRepositorySearch search = new MavenRepositorySearch();
SearchResults origSearchResults = build(63, new SearchResultLimits(0));
SearchResults searchResults = search.paginate(origSearchResults);
assertEquals(30, searchResults.getReturnedHitsCount());
origSearchResults = build(63, new SearchResultLimits(1));
searchResults = search.paginate(origSearchResults);
assertEquals(30, searchResults.getReturnedHitsCount());
}
Aggregations