Search in sources :

Example 6 with ArtifactClient

use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.

the class ArtifactEndpointTest method shouldDeleteTemporaryQualityLevel.

@Test
public void shouldDeleteTemporaryQualityLevel() throws ClientException {
    Artifact artifact = Artifact.builder().artifactQuality(ArtifactQuality.TEMPORARY).buildCategory(BuildCategory.STANDARD).filename("temp-builtArtifactInsert3.jar").identifier("integration-test:temp-built-artifact-insert3:jar:1.0").targetRepository(targetRepositoryRef).md5("insert-md5-131").sha1("insert-131").sha256("insert-131").size(131L).build();
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
    Artifact inserted = client.create(artifact);
    String id = inserted.getId();
    Artifact retrieved = client.getSpecific(id);
    Assertions.assertThat(retrieved.getArtifactQuality()).isEqualTo(ArtifactQuality.TEMPORARY);
    String REASON = "This artifact can be nuked";
    client.createQualityLevelRevision(id, "DELEted", REASON);
    Artifact updatedArtifactDB = client.getSpecific(id);
    assertThat(updatedArtifactDB.getId()).isEqualTo(retrieved.getId());
    assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(ArtifactQuality.DELETED);
    assertThat(updatedArtifactDB.getQualityLevelReason()).isEqualTo(REASON);
    assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(retrieved.getCreationTime());
    assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(retrieved.getModificationTime());
    assertThat(updatedArtifactDB.getModificationUser().getUsername()).isEqualTo("system");
}
Also used : ArtifactClient(org.jboss.pnc.client.ArtifactClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with ArtifactClient

use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.

the class ArtifactEndpointTest method testGetAllArtifactsFilteredByIdentifier.

@Test
public void testGetAllArtifactsFilteredByIdentifier() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<ArtifactInfo> result;
    result = client.getAllFiltered("*demo:*:jar:*", null, null);
    assertThat(result).allSatisfy(a -> assertThat(a.getIdentifier().contains("demo:") && a.getIdentifier().contains(":jar:")));
    result = client.getAllFiltered("demo:built-artifact11:pom:*", null, null);
    // from DatabaseDataInitializer
    assertThat(result).hasSize(1);
    result = client.getAllFiltered("demo:built-artifact22:jar:1.0", null, null);
    // from DatabaseDataInitializer
    assertThat(result).hasSize(1);
}
Also used : ArtifactInfo(org.jboss.pnc.dto.response.ArtifactInfo) ArtifactClient(org.jboss.pnc.client.ArtifactClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 8 with ArtifactClient

use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.

the class ArtifactEndpointTest method setTargetRepository.

@Before
public void setTargetRepository() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    List<Artifact> artifacts = new ArrayList<>();
    for (Artifact artifact : client.getAll(null, null, null)) {
        artifacts.add(artifact);
    }
    targetRepositoryRef = artifacts.get(0).getTargetRepository();
    artifactRest1 = artifacts.get(0);
    artifactRest2 = artifacts.get(1);
    artifactRest3 = artifacts.get(4);
    artifactRest4 = artifacts.get(6);
    logger.debug("Using targetRepositoryRef: {}", targetRepositoryRef);
}
Also used : ArtifactClient(org.jboss.pnc.client.ArtifactClient) ArrayList(java.util.ArrayList) Artifact(org.jboss.pnc.dto.Artifact) Before(org.junit.Before)

Example 9 with ArtifactClient

use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.

the class ArtifactEndpointTest method testGetSpecificArtifact.

@Test
public void testGetSpecificArtifact() throws ClientException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    Artifact artifact = client.getSpecific(artifactRest1.getId());
    assertThat(artifact.getId()).isEqualTo(artifactRest1.getId());
}
Also used : ArtifactClient(org.jboss.pnc.client.ArtifactClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with ArtifactClient

use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.

the class ArtifactEndpointTest method shouldModifyModificationFields.

@Test
public void shouldModifyModificationFields() throws ClientException {
    String id = artifactRest1.getId();
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
    // Updating an audited property should create a new revision and should alter modificationUser and
    // modificationTime. But, creationTime should never be updated, not creationUser
    Artifact artifact = client.getSpecific(id);
    Artifact updatedArtifact = artifact.toBuilder().modificationTime(Instant.now()).artifactQuality(ArtifactQuality.DEPRECATED).creationTime(Instant.now()).size(1000L).build();
    client.update(id, updatedArtifact);
    Artifact updatedArtifactDB = client.getSpecific(id);
    assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
    assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(updatedArtifact.getArtifactQuality());
    assertThat(updatedArtifactDB.getSize()).isEqualTo(updatedArtifact.getSize());
    assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
    assertThat(updatedArtifactDB.getCreationUser()).isEqualTo(artifact.getCreationUser());
    assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(artifact.getModificationTime());
    assertThat(updatedArtifactDB.getCreationTime()).isNotEqualTo(updatedArtifact.getCreationTime());
    assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(updatedArtifact.getModificationTime());
}
Also used : ArtifactClient(org.jboss.pnc.client.ArtifactClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

ArtifactClient (org.jboss.pnc.client.ArtifactClient)31 ContainerTest (org.jboss.pnc.test.category.ContainerTest)30 Test (org.junit.Test)30 Artifact (org.jboss.pnc.dto.Artifact)22 ArtifactInfo (org.jboss.pnc.dto.response.ArtifactInfo)4 ArtifactRevision (org.jboss.pnc.dto.ArtifactRevision)3 HashSet (java.util.HashSet)2 BuildClient (org.jboss.pnc.client.BuildClient)2 Build (org.jboss.pnc.dto.Build)2 ArrayList (java.util.ArrayList)1 BadRequestException (javax.ws.rs.BadRequestException)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 ClientException (org.jboss.pnc.client.ClientException)1 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)1 MilestoneInfo (org.jboss.pnc.dto.response.MilestoneInfo)1 RepositoryType (org.jboss.pnc.enums.RepositoryType)1 Before (org.junit.Before)1