Search in sources :

Example 16 with SearchService

use of org.apache.archiva.rest.api.services.SearchService in project archiva by apache.

the class SearchServiceTest method searchWithSearchUnknwownRepoId.

@Test
public /**
 * ensure we don't return response for an unknown repo
 */
void searchWithSearchUnknwownRepoId() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
    searchRequest.setRepositories(Arrays.asList("tototititata"));
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    assertNotNull(artifacts);
    assertTrue(" not 0 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + artifacts.size() + ":" + artifacts, artifacts.size() == 0);
}
Also used : SearchRequest(org.apache.archiva.rest.api.model.SearchRequest) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Example 17 with SearchService

use of org.apache.archiva.rest.api.services.SearchService in project archiva by apache.

the class SearchServiceTest method quickSearchOnArtifactIdGuest.

/**
 * same search but with Guest user
 *
 * @throws Exception
 */
@Test
public void quickSearchOnArtifactIdGuest() throws Exception {
    SearchService searchService = getSearchService(null);
    // START SNIPPET: quick-search
    List<Artifact> artifacts = searchService.quickSearch("commons-logging");
    // return all artifacts with groupId OR artifactId OR version OR packaging OR className
    // NOTE : only artifacts with classifier empty are returned
    // END SNIPPET: quick-search
    assertNotNull(artifacts);
    assertTrue(" not 6 results for commons-logging search but " + artifacts.size() + ":" + artifacts, artifacts.size() == 6);
    log.info("artifacts for commons-logging size {} search {}", artifacts.size(), artifacts);
}
Also used : SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Aggregations

SearchService (org.apache.archiva.rest.api.services.SearchService)17 Test (org.junit.Test)15 Artifact (org.apache.archiva.maven2.model.Artifact)14 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)9 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)2 Path (java.nio.file.Path)2 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)2 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)2 RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)2 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)2 ChecksumSearch (org.apache.archiva.rest.api.model.ChecksumSearch)2 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)2 ProxyConnectorService (org.apache.archiva.rest.api.services.ProxyConnectorService)2 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)2 RepositoryGroupService (org.apache.archiva.rest.api.services.RepositoryGroupService)2 UiConfiguration (org.apache.archiva.admin.model.beans.UiConfiguration)1