Search in sources :

Example 16 with SearchFields

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());
}
Also used : SearchFields(org.apache.archiva.indexer.search.SearchFields) SearchResults(org.apache.archiva.indexer.search.SearchResults) Test(org.junit.Test)

Example 17 with SearchFields

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());
}
Also used : SearchFields(org.apache.archiva.indexer.search.SearchFields) ArrayList(java.util.ArrayList) SearchResults(org.apache.archiva.indexer.search.SearchResults) Test(org.junit.Test)

Example 18 with SearchFields

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());
}
Also used : Path(java.nio.file.Path) SearchFields(org.apache.archiva.indexer.search.SearchFields) ArrayList(java.util.ArrayList) SearchResults(org.apache.archiva.indexer.search.SearchResults) Test(org.junit.Test)

Example 19 with SearchFields

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());
}
Also used : SearchFields(org.apache.archiva.indexer.search.SearchFields) ArrayList(java.util.ArrayList) SearchResults(org.apache.archiva.indexer.search.SearchResults) Test(org.junit.Test)

Aggregations

SearchFields (org.apache.archiva.indexer.search.SearchFields)19 SearchResults (org.apache.archiva.indexer.search.SearchResults)16 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)11 RepositorySearchException (org.apache.archiva.indexer.search.RepositorySearchException)6 SearchResultHit (org.apache.archiva.indexer.search.SearchResultHit)5 Path (java.nio.file.Path)3 SearchResultLimits (org.apache.archiva.indexer.search.SearchResultLimits)3 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)3 URI (java.net.URI)1 TreeMap (java.util.TreeMap)1 Artifact (org.apache.archiva.maven2.model.Artifact)1 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)1