Search in sources :

Example 1 with SearchService

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

the class SearchServiceTest method quickSearchOnArtifactId.

@Test
public void quickSearchOnArtifactId() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    // 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)

Example 2 with SearchService

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

the class SearchServiceTest method search_with_sha1.

/**
 * sha1 commons-logging 1.1 ba24d5de831911b684c92cd289ed5ff826271824
 */
@Test
public void search_with_sha1() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    List<Artifact> artifacts = searchService.getArtifactByChecksum(new ChecksumSearch(null, "ba24d5de831911b684c92cd289ed5ff826271824"));
    Assertions.assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
}
Also used : ChecksumSearch(org.apache.archiva.rest.api.model.ChecksumSearch) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Example 3 with SearchService

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

the class SearchServiceTest method searchWithSearchNoRepos.

@Test
public /**
 * ensure we revert to all observable repos in case of no repo in the request
 */
void searchWithSearchNoRepos() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
    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() == 1);
    log.info("artifact url {}", artifacts.get(0).getUrl());
}
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 4 with SearchService

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

the class SearchServiceTest method getSearchArtifactsWithOnlyClassifier.

@Test
public /**
 * test we don't return 2 artifacts pom + zip one
 */
void getSearchArtifactsWithOnlyClassifier() throws Exception {
    // force guest user creation if not exists
    if (getUserService(authorizationHeader).getGuestUser() == null) {
        assertNotNull(getUserService(authorizationHeader).createGuestUser());
    }
    createAndIndexRepo(TEST_REPO, "src/test/repo-with-classifier-only");
    SearchService searchService = getSearchService(authorizationHeader);
    SearchRequest searchRequest = new SearchRequest("org.foo", "studio-all-update-site", null, null, null, Arrays.asList(TEST_REPO));
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    log.info("artifacts: {}", artifacts);
    assertEquals(1, artifacts.size());
}
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 5 with SearchService

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

the class SearchServiceTest method searchWithSearchRequestExportPackageOneVersion.

@Test
public void searchWithSearchRequestExportPackageOneVersion() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setBundleExportPackage("org.apache.karaf.features.command.completers");
    searchRequest.setRepositories(Arrays.asList(TEST_REPO));
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    assertNotNull(artifacts);
    assertTrue(" not 1 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " + artifacts.size() + ":" + artifacts, artifacts.size() == 1);
    log.info("artifact url {}", artifacts.get(0).getUrl());
}
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)

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