Search in sources :

Example 26 with Artifact

use of org.jboss.pnc.dto.Artifact 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)

Example 27 with Artifact

use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.

the class BuildEndpointTest method shouldSetBuiltArtifacts.

@Test
public void shouldSetBuiltArtifacts() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = buildId;
    RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
    Set<Integer> artifactIds = artifactIds(artifacts);
    assertThat(artifactIds).containsExactlyInAnyOrder(100, 101);
    client.setBuiltArtifacts(buildRecordId, Collections.singletonList("104"));
    RemoteCollection<Artifact> newBuiltArtifacts = client.getBuiltArtifacts(buildRecordId);
    Set<Integer> updatedArtifactIds = artifactIds(newBuiltArtifacts);
    assertThat(updatedArtifactIds).containsExactlyInAnyOrder(104);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 28 with Artifact

use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.

the class BuildEndpointTest method shouldSetDependentArtifacts.

@Test
public void shouldSetDependentArtifacts() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = buildId;
    RemoteCollection<Artifact> artifacts = client.getDependencyArtifacts(buildRecordId);
    Set<Integer> artifactIds = artifactIds(artifacts);
    assertThat(artifactIds).contains(104, 105);
    client.setDependentArtifacts(buildRecordId, Collections.singletonList("102"));
    RemoteCollection<Artifact> newDependencyArtifacts = client.getDependencyArtifacts(buildRecordId);
    Set<Integer> updatedArtifactIds = artifactIds(newDependencyArtifacts);
    assertThat(updatedArtifactIds).contains(102);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 29 with Artifact

use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.

the class ArtifactProviderTest method testStoreWithId.

@Test
public void testStoreWithId() {
    final String identifier = "foo:bar:0.0.1";
    Artifact artifact = Artifact.builder().id("123").identifier(identifier).artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).build();
    try {
        provider.store(artifact);
        fail("Validation exception expected");
    } catch (DTOValidationException ex) {
    // ok
    }
}
Also used : DTOValidationException(org.jboss.pnc.facade.validation.DTOValidationException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Artifact(org.jboss.pnc.dto.Artifact) Test(org.junit.Test)

Example 30 with Artifact

use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.

the class ArtifactProviderTest method testGetSpecific.

@Test
public void testGetSpecific() {
    fillRepository(artifacts);
    Artifact specific = provider.getSpecific(Integer.toString(artifact1.getId()));
    assertThat(specific.getId()).isEqualTo(artifact1.getId().toString());
    assertThat(specific.getIdentifier()).isEqualTo(artifact1.getIdentifier());
    assertThat(specific.getSha256()).isEqualTo(artifact1.getSha256());
}
Also used : Artifact(org.jboss.pnc.dto.Artifact) Test(org.junit.Test)

Aggregations

Artifact (org.jboss.pnc.dto.Artifact)31 Test (org.junit.Test)28 ContainerTest (org.jboss.pnc.test.category.ContainerTest)24 ArtifactClient (org.jboss.pnc.client.ArtifactClient)22 BuildClient (org.jboss.pnc.client.BuildClient)4 ArrayList (java.util.ArrayList)3 ArtifactRevision (org.jboss.pnc.dto.ArtifactRevision)3 List (java.util.List)2 TargetRepository (org.jboss.pnc.dto.TargetRepository)2 DTOValidationException (org.jboss.pnc.facade.validation.DTOValidationException)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Iterator (java.util.Iterator)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 BadRequestException (javax.ws.rs.BadRequestException)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1