Search in sources :

Example 11 with Artifact

use of org.apache.archiva.maven2.model.Artifact 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 12 with Artifact

use of org.apache.archiva.maven2.model.Artifact 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 13 with Artifact

use of org.apache.archiva.maven2.model.Artifact 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 14 with Artifact

use of org.apache.archiva.maven2.model.Artifact 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)

Example 15 with Artifact

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

the class SearchServiceTest method searchWithSearchRequestBundleSymbolicNameTwoVersion.

@Test
public void searchWithSearchRequestBundleSymbolicNameTwoVersion() throws Exception {
    UiConfiguration uiConfiguration = new UiConfiguration();
    uiConfiguration.setApplicationUrl(null);
    getArchivaAdministrationService().setUiConfiguration(uiConfiguration);
    SearchService searchService = getSearchService(authorizationHeader);
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setBundleSymbolicName("org.apache.karaf.features.core");
    List<Artifact> artifacts = searchService.searchArtifacts(searchRequest);
    assertThat(artifacts).isNotNull().hasSize(2);
    for (Artifact artifact : artifacts) {
        log.info("url: {}", artifact.getUrl());
        String version = artifact.getVersion();
        // 
        Assertions.assertThat(artifact.getUrl()).isEqualTo("http://localhost:" + port + "/repository/test-repo/org/apache/karaf/features/org.apache.karaf.features.core/" + version + "/org.apache.karaf.features.core-" + version + ".jar");
    }
}
Also used : SearchRequest(org.apache.archiva.rest.api.model.SearchRequest) UiConfiguration(org.apache.archiva.admin.model.beans.UiConfiguration) SearchService(org.apache.archiva.rest.api.services.SearchService) Artifact(org.apache.archiva.maven2.model.Artifact) Test(org.junit.Test)

Aggregations

Artifact (org.apache.archiva.maven2.model.Artifact)37 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)14 SearchService (org.apache.archiva.rest.api.services.SearchService)14 BrowseService (org.apache.archiva.rest.api.services.BrowseService)11 Path (java.nio.file.Path)10 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)9 Artifact (se.light.assembly64.model.Artifact)9 List (java.util.List)8 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)8 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)8 File (java.io.File)7 IOException (java.io.IOException)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)6 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5