Search in sources :

Example 31 with ArtifactClient

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

the class ArtifactEndpointTest method shouldNotModifyCreationModificationFields.

@Test
public void shouldNotModifyCreationModificationFields() throws ClientException {
    String id = artifactRest3.getId();
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
    // Updating a not audited property should not create a new revision and should not alter modificationUser and
    // modificationTime. Also, creationTime should never be updated, not creationUser
    Artifact artifact = client.getSpecific(id);
    Artifact updatedArtifact = artifact.toBuilder().modificationTime(Instant.now()).md5("md5").creationTime(Instant.now()).size(1000L).build();
    client.update(id, updatedArtifact);
    Artifact updatedArtifactDB = client.getSpecific(id);
    assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
    assertThat(updatedArtifactDB.getMd5()).isEqualTo(updatedArtifact.getMd5());
    assertThat(updatedArtifactDB.getSize()).isEqualTo(updatedArtifact.getSize());
    assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
    assertThat(updatedArtifactDB.getCreationUser()).isEqualTo(artifact.getCreationUser());
    assertThat(updatedArtifactDB.getModificationTime()).isEqualTo(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