Search in sources :

Example 1 with BrowseService

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

the class BrowseServiceTest method getProjectVersionMetadata.

@Test
public void getProjectVersionMetadata() throws Exception {
    BrowseService browseService = getBrowseService(authorizationHeader, true);
    ProjectVersionMetadata metadata = browseService.getProjectVersionMetadata("org.apache.karaf.features", "org.apache.karaf.features.core", TEST_REPO_ID);
    assertThat(metadata).isNotNull();
}
Also used : ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Test(org.junit.Test)

Example 2 with BrowseService

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

the class BrowseServiceTest method listUserRepositories.

@Test
public void listUserRepositories() throws Exception {
    initSourceTargetRepo();
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    List<ManagedRepository> browseResult = browseService.getUserRepositories();
    assertThat(browseResult).isNotNull().isNotEmpty().hasSize(5);
    List<String> repIds = new ArrayList<>();
    for (ManagedRepository rep : browseResult) {
        repIds.add(rep.getId());
    }
    assertThat(repIds).contains("internal", "snapshots", "test-repo", "test-copy-target", "test-origin-repo");
}
Also used : ManagedRepository(org.apache.archiva.admin.model.beans.ManagedRepository) ArrayList(java.util.ArrayList) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Test(org.junit.Test)

Example 3 with BrowseService

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

the class BrowseServiceTest method metadatagetthenadd.

@Test
public void metadatagetthenadd() throws Exception {
    scanRepo(TEST_REPO_ID);
    waitForScanToComplete(TEST_REPO_ID);
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    Map<String, String> metadatas = toMap(browseService.getMetadatas("commons-cli", "commons-cli", "1.0", TEST_REPO_ID));
    assertThat(metadatas).isNotNull().isEmpty();
    browseService.addMetadata("commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID);
    metadatas = toMap(browseService.getMetadatas("commons-cli", "commons-cli", "1.0", TEST_REPO_ID));
    assertThat(metadatas).isNotNull().isNotEmpty().contains(MapEntry.entry("wine", "bordeaux"));
}
Also used : BrowseService(org.apache.archiva.rest.api.services.BrowseService) Test(org.junit.Test)

Example 4 with BrowseService

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

the class BrowseServiceTest method listUserManagableRepositories.

@Test
public void listUserManagableRepositories() throws Exception {
    initSourceTargetRepo();
    // Giving the guest user a manager role
    String name = "Repository Manager - internal";
    Role role = getRoleManagementService(authorizationHeader).getRole(name);
    role.setUsers(Arrays.asList(getUserService(authorizationHeader).getUser("guest")));
    getRoleManagementService(authorizationHeader).updateRoleUsers(role);
    // browseService with guest user
    BrowseService browseService = getBrowseService("", false);
    List<ManagedRepository> browseResult = browseService.getUserManagableRepositories();
    assertThat(browseResult).isNotNull().isNotEmpty().hasSize(1);
    List<String> repIds = new ArrayList<>();
    for (ManagedRepository rep : browseResult) {
        repIds.add(rep.getId());
    }
    assertThat(repIds).contains("internal");
}
Also used : Role(org.apache.archiva.redback.rest.api.model.Role) ManagedRepository(org.apache.archiva.admin.model.beans.ManagedRepository) ArrayList(java.util.ArrayList) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Test(org.junit.Test)

Example 5 with BrowseService

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

the class BrowseServiceTest method readArtifactContentText.

@Test
public void readArtifactContentText() throws Exception {
    BrowseService browseService = getBrowseService(authorizationHeader, true);
    WebClient.client(browseService).accept(MediaType.TEXT_PLAIN);
    String text = browseService.getArtifactContentText("commons-logging", "commons-logging", "1.1", "sources", null, "org/apache/commons/logging/LogSource.java", TEST_REPO_ID).getContent();
    log.debug("text: {}", text);
    assertThat(text).contains("package org.apache.commons.logging;").contains("public class LogSource {");
}
Also used : BrowseService(org.apache.archiva.rest.api.services.BrowseService) Test(org.junit.Test)

Aggregations

BrowseService (org.apache.archiva.rest.api.services.BrowseService)29 Test (org.junit.Test)28 Artifact (org.apache.archiva.maven2.model.Artifact)11 Path (java.nio.file.Path)5 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)5 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)5 BrowseResult (org.apache.archiva.rest.api.model.BrowseResult)4 VersionsList (org.apache.archiva.rest.api.model.VersionsList)4 ArtifactContentEntry (org.apache.archiva.rest.api.model.ArtifactContentEntry)3 BrowseResultEntry (org.apache.archiva.rest.api.model.BrowseResultEntry)3 ArrayList (java.util.ArrayList)2 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 HashMap (java.util.HashMap)1 BadRequestException (javax.ws.rs.BadRequestException)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)1 Role (org.apache.archiva.redback.rest.api.model.Role)1 MetadataAddRequest (org.apache.archiva.rest.api.model.MetadataAddRequest)1 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)1