Search in sources :

Example 1 with VersionsList

use of org.apache.archiva.rest.api.model.VersionsList in project archiva by apache.

the class RepositoriesServiceTest method deleteArtifact.

@Test
public void deleteArtifact() throws Exception {
    initSourceTargetRepo();
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    List<Artifact> artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
    log.info("artifacts: {}", artifacts);
    assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
    VersionsList versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
    assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(2);
    log.info("artifacts.size: {}", artifacts.size());
    try {
        Path artifactFile = Paths.get("target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar");
        assertTrue("artifact not exists:" + artifactFile.toString(), Files.exists(artifactFile));
        Artifact artifact = new Artifact();
        artifact.setGroupId("org.apache.karaf.features");
        artifact.setArtifactId("org.apache.karaf.features.core");
        artifact.setVersion("2.2.2");
        artifact.setPackaging("jar");
        artifact.setContext(SOURCE_REPO_ID);
        RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
        repositoriesService.deleteArtifact(artifact);
        assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
        artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
        assertThat(artifacts).isNotNull().isEmpty();
        versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
        assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(1);
    } finally {
        cleanRepos();
    }
}
Also used : Path(java.nio.file.Path) RepositoriesService(org.apache.archiva.rest.api.services.RepositoriesService) ManagedRepositoriesService(org.apache.archiva.rest.api.services.ManagedRepositoriesService) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Artifact(org.apache.archiva.maven2.model.Artifact) VersionsList(org.apache.archiva.rest.api.model.VersionsList) Test(org.junit.Test)

Example 2 with VersionsList

use of org.apache.archiva.rest.api.model.VersionsList in project archiva by apache.

the class RepositoriesServiceTest method deleteArtifactVersion.

/**
 * delete a version of an artifact without packaging
 *
 * @throws Exception
 */
@Test
public void deleteArtifactVersion() throws Exception {
    initSourceTargetRepo();
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    List<Artifact> artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
    log.info("artifacts: {}", artifacts);
    assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
    VersionsList versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
    assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(2);
    log.info("artifacts.size: {}", artifacts.size());
    try {
        Path artifactFile = Paths.get("target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar");
        assertTrue("artifact not exists:" + artifactFile, Files.exists(artifactFile));
        Artifact artifact = new Artifact();
        artifact.setGroupId("org.apache.karaf.features");
        artifact.setArtifactId("org.apache.karaf.features.core");
        artifact.setVersion("2.2.2");
        artifact.setContext(SOURCE_REPO_ID);
        RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
        repositoriesService.deleteArtifact(artifact);
        assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
        artifacts = browseService.getArtifactDownloadInfos("org.apache.karaf.features", "org.apache.karaf.features.core", "2.2.2", SOURCE_REPO_ID);
        assertThat(artifacts).isNotNull().isEmpty();
        versionsList = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", SOURCE_REPO_ID);
        assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(1);
    } finally {
        cleanRepos();
    }
}
Also used : Path(java.nio.file.Path) RepositoriesService(org.apache.archiva.rest.api.services.RepositoriesService) ManagedRepositoriesService(org.apache.archiva.rest.api.services.ManagedRepositoriesService) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Artifact(org.apache.archiva.maven2.model.Artifact) VersionsList(org.apache.archiva.rest.api.model.VersionsList) Test(org.junit.Test)

Example 3 with VersionsList

use of org.apache.archiva.rest.api.model.VersionsList in project archiva by apache.

the class BrowseServiceTest method versionsList.

@Test
public void versionsList() throws Exception {
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    VersionsList versions = browseService.getVersionsList("org.apache.karaf.features", "org.apache.karaf.features.core", TEST_REPO_ID);
    assertThat(versions).isNotNull();
    // 
    assertThat(versions.getVersions()).isNotNull().isNotEmpty().hasSize(// 
    2).contains("2.2.1", "2.2.2");
}
Also used : BrowseService(org.apache.archiva.rest.api.services.BrowseService) VersionsList(org.apache.archiva.rest.api.model.VersionsList) Test(org.junit.Test)

Example 4 with VersionsList

use of org.apache.archiva.rest.api.model.VersionsList in project archiva by apache.

the class RepositoriesServiceTest method deleteArtifactWithClassifier.

@Test
public void deleteArtifactWithClassifier() throws Exception {
    initSourceTargetRepo();
    BrowseService browseService = getBrowseService(authorizationHeader, false);
    List<Artifact> artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
    assertThat(artifacts).isNotNull().isNotEmpty().hasSize(3);
    VersionsList versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
    assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
    log.info("artifacts.size: {}", artifacts.size());
    try {
        Path artifactFile = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar");
        Path artifactFilemd5 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.md5");
        Path artifactFilesha1 = Paths.get("target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.sha1");
        assertTrue("artifact not exists:" + artifactFile, Files.exists(artifactFile));
        assertTrue("md5 not exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
        assertTrue("sha1 not exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
        Artifact artifact = new Artifact();
        artifact.setGroupId("commons-logging");
        artifact.setArtifactId("commons-logging");
        artifact.setVersion("1.0.1");
        artifact.setClassifier("javadoc");
        artifact.setPackaging("jar");
        artifact.setContext(SOURCE_REPO_ID);
        RepositoriesService repositoriesService = getRepositoriesService(authorizationHeader);
        repositoriesService.deleteArtifact(artifact);
        assertFalse("artifact not deleted exists:" + artifactFile, Files.exists(artifactFile));
        assertFalse("md5 still exists:" + artifactFilemd5, Files.exists(artifactFilemd5));
        assertFalse("sha1 still exists:" + artifactFilesha1, Files.exists(artifactFilesha1));
        artifacts = browseService.getArtifactDownloadInfos("commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID);
        log.info("artifact: {}", artifacts);
        assertThat(artifacts).isNotNull().isNotEmpty().hasSize(2);
        versionsList = browseService.getVersionsList("commons-logging", "commons-logging", SOURCE_REPO_ID);
        log.info("versionsList: {}", versionsList);
        assertThat(versionsList.getVersions()).isNotNull().isNotEmpty().hasSize(6);
    } finally {
        cleanRepos();
    }
}
Also used : Path(java.nio.file.Path) RepositoriesService(org.apache.archiva.rest.api.services.RepositoriesService) ManagedRepositoriesService(org.apache.archiva.rest.api.services.ManagedRepositoriesService) BrowseService(org.apache.archiva.rest.api.services.BrowseService) Artifact(org.apache.archiva.maven2.model.Artifact) VersionsList(org.apache.archiva.rest.api.model.VersionsList) Test(org.junit.Test)

Aggregations

VersionsList (org.apache.archiva.rest.api.model.VersionsList)4 BrowseService (org.apache.archiva.rest.api.services.BrowseService)4 Test (org.junit.Test)4 Path (java.nio.file.Path)3 Artifact (org.apache.archiva.maven2.model.Artifact)3 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)3 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)3