Search in sources :

Example 16 with Artifact

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

the class ArtifactEndpointTest method testGetAllArtifactsWithMd5.

@Test
public void testGetAllArtifactsWithMd5() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Artifact> artifacts = client.getAll(null, artifactRest1.getMd5(), null);
    // artifacts 1 and 2 have same MD5
    assertThat(artifacts).hasSize(2).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest1.getId(), artifactRest2.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 17 with Artifact

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

the class ArtifactEndpointTest method testGetAllArtifacts.

@Test
public void testGetAllArtifacts() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Artifact> all = client.getAll(null, null, null);
    // from DatabaseDataInitializer
    assertThat(all).hasSize(10);
}
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 18 with Artifact

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

the class ArtifactEndpointTest method testGetAllArtifactsWithMd5AndSha1.

@Test
public void testGetAllArtifactsWithMd5AndSha1() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Artifact> artifacts = client.getAll(null, artifactRest2.getMd5(), artifactRest2.getSha1());
    assertThat(artifacts).hasSize(1).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest2.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 19 with Artifact

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

the class ArtifactEndpointTest method shouldNotModifyBlacklistedQualityLevel.

@Test
public void shouldNotModifyBlacklistedQualityLevel() throws ClientException {
    String id = artifactRest3.getId();
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
    String REASON = "This artifact has severe CVEs";
    Artifact artifact = client.getSpecific(id);
    client.createQualityLevelRevision(id, "BLACKLISTED", REASON);
    Artifact updatedArtifactDB = client.getSpecific(id);
    assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
    assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
    assertThat(updatedArtifactDB.getQualityLevelReason()).isEqualTo(REASON);
    assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
    assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(artifact.getModificationTime());
    assertThat(updatedArtifactDB.getModificationUser().getUsername()).isEqualTo("system");
    assertThatThrownBy(() -> client.createQualityLevelRevision(id, "DEPRECATED", REASON)).hasCauseInstanceOf(ClientErrorException.class);
}
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 20 with Artifact

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

the class ArtifactEndpointTest method testGetAllArtifactsWithSha256.

@Test
public void testGetAllArtifactsWithSha256() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Artifact> artifacts = client.getAll(artifactRest1.getSha256(), null, null);
    // artifacts 1 and 3 have same SHA256
    assertThat(artifacts).hasSize(2).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest1.getId(), artifactRest4.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)

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