Search in sources :

Example 31 with Artifact

use of org.apache.archiva.maven.model.Artifact in project archiva by apache.

the class SearchServiceTest method searchWithSearchRequestBundleSymbolicNameOneVersion.

@Test
public void searchWithSearchRequestBundleSymbolicNameOneVersion() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    // START SNIPPET: searchservice-with-osgi
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setBundleSymbolicName("org.apache.karaf.features.command");
    // END SNIPPET: searchservice-with-osgi
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    assertNotNull(artifacts);
    assertTrue(" not 1 results for Bundle Symbolic Name org.apache.karaf.features.command but " + artifacts.size() + ":" + artifacts, artifacts.size() == 1);
}
Also used : SearchRequest(org.apache.archiva.rest.api.model.SearchRequest) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven.model.Artifact) Test(org.junit.Test)

Example 32 with Artifact

use of org.apache.archiva.maven.model.Artifact 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.maven.model.Artifact) Test(org.junit.Test)

Example 33 with Artifact

use of org.apache.archiva.maven.model.Artifact in project archiva by apache.

the class SearchServiceTest method searchWithSearchRequestGroupIdAndArtifactIdAndClassifier.

@Test
public void searchWithSearchRequestGroupIdAndArtifactIdAndClassifier() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    // START SNIPPET: searchservice-with-classifier
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setGroupId("commons-logging");
    searchRequest.setArtifactId("commons-logging");
    searchRequest.setClassifier("sources");
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    // END SNIPPET: searchservice-with-classifier
    assertNotNull(artifacts);
    assertTrue(" not 2 results for commons-logging search but " + artifacts.size() + ":" + artifacts, artifacts.size() == 2);
    log.info("artifacts for commons-logging size {} search {}", artifacts.size(), artifacts);
}
Also used : SearchRequest(org.apache.archiva.rest.api.model.SearchRequest) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven.model.Artifact) Test(org.junit.Test)

Example 34 with Artifact

use of org.apache.archiva.maven.model.Artifact 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.maven.model.Artifact) Test(org.junit.Test)

Example 35 with Artifact

use of org.apache.archiva.maven.model.Artifact in project archiva by apache.

the class SearchServiceTest method search_with_md5.

/**
 * md5 commons-logging 1.1 6b62417e77b000a87de66ee3935edbf5
 */
@Test
public void search_with_md5() throws Exception {
    SearchService searchService = getSearchService(authorizationHeader);
    List<Artifact> artifacts = searchService.getArtifactByChecksum(new ChecksumSearch(null, "6b62417e77b000a87de66ee3935edbf5"));
    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.maven.model.Artifact) Test(org.junit.Test)

Aggregations

Artifact (org.apache.archiva.maven.model.Artifact)37 Test (org.junit.Test)29 SearchService (org.apache.archiva.rest.api.services.SearchService)14 BrowseService (org.apache.archiva.rest.api.services.BrowseService)11 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)9 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)8 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)8 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)7 Path (java.nio.file.Path)6 ArrayList (java.util.ArrayList)4 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)3 VersionsList (org.apache.archiva.rest.api.model.VersionsList)3 BadRequestException (javax.ws.rs.BadRequestException)2 ForbiddenException (javax.ws.rs.ForbiddenException)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 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)2