use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method testSearchWithUnknownRepo.
@Test
public void testSearchWithUnknownRepo() throws Exception {
createIndexContainingMoreArtifacts(true);
List<String> selectedRepos = Arrays.asList("foo");
SearchFields searchFields = new SearchFields();
searchFields.setClassName("SomeClass");
searchFields.setRepositories(selectedRepos);
archivaConfigControl.replay();
SearchResults results = search.search("user", searchFields, null);
archivaConfigControl.verify();
assertNotNull(results);
assertEquals(0, results.getHits().size());
}
use of org.apache.archiva.indexer.search.SearchFields in project archiva by apache.
the class MavenRepositorySearchTest method testAdvancedSearchNoIndexFound.
@Test
public void testAdvancedSearchNoIndexFound() throws Exception {
List<String> selectedRepos = new ArrayList<>();
selectedRepos.add(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setGroupId("org.apache.archiva");
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.SearchFields 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.SearchFields 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());
}
Aggregations