Search in sources :

Example 11 with ArtifactClient

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

the class ArtifactEndpointTest method testGetAllArtifactsFilteredByQualitiesList.

@Test
public void testGetAllArtifactsFilteredByQualitiesList() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<ArtifactInfo> result;
    result = client.getAllFiltered(null, new HashSet<>(Arrays.asList(ArtifactQuality.NEW)), null);
    assertThat(result).allSatisfy(a -> assertThat(a.getArtifactQuality().equals(ArtifactQuality.NEW)));
    result = client.getAllFiltered(null, new HashSet<>(Arrays.asList(ArtifactQuality.VERIFIED, ArtifactQuality.DELETED)), null);
    // from DatabaseDataInitializer
    assertThat(result).hasSize(2);
}
Also used : ArtifactInfo(org.jboss.pnc.dto.response.ArtifactInfo) ArtifactClient(org.jboss.pnc.client.ArtifactClient) HashSet(java.util.HashSet) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 12 with ArtifactClient

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

the class ArtifactEndpointTest method testGetAllArtifactsFilteredByBuildCategories.

@Test
public void testGetAllArtifactsFilteredByBuildCategories() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<ArtifactInfo> result;
    result = client.getAllFiltered(null, null, null, new HashSet<>(Arrays.asList(BuildCategory.STANDARD)));
    assertThat(result).allSatisfy(a -> assertThat(a.getBuildCategory().equals(BuildCategory.STANDARD)));
    result = client.getAllFiltered(null, null, null, new HashSet<>(Arrays.asList(BuildCategory.SERVICE)));
    // from DatabaseDataInitializer
    assertThat(result).hasSize(2);
}
Also used : ArtifactInfo(org.jboss.pnc.dto.response.ArtifactInfo) ArtifactClient(org.jboss.pnc.client.ArtifactClient) HashSet(java.util.HashSet) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 13 with ArtifactClient

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

the class ArtifactEndpointTest method shouldUpdateArtifact.

@Test
public void shouldUpdateArtifact() throws ClientException {
    String id = artifactRest1.getId();
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
    Artifact artifact = client.getSpecific(id);
    final long size = artifact.getSize() + 10;
    Artifact updatedArtifact = artifact.toBuilder().size(size).build();
    client.update(id, updatedArtifact);
    Artifact artifact2 = client.getSpecific(id);
    assertThat(artifact2.getSize()).isEqualTo(size);
}
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 14 with ArtifactClient

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

the class BuildEndpointTest method shouldReturnForbiddenCodeForPushOfBadQualityArtifact.

@Test
public void shouldReturnForbiddenCodeForPushOfBadQualityArtifact() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    ArtifactClient artifactClient = new ArtifactClient(RestClientConfiguration.asSystem());
    Artifact badQuality = artifactClient.create(Artifact.builder().artifactQuality(ArtifactQuality.DELETED).buildCategory(BuildCategory.STANDARD).filename("builtArtifactInsert2.jar").identifier("integration-test:built-artifact:jar:1.0").targetRepository(artifactClient.getSpecific("100").getTargetRepository()).md5("insert-md5-2").sha1("insert-2").sha256("insert-2").size(10L).build());
    client.setBuiltArtifacts(build2Id, Collections.singletonList(badQuality.getId()));
    assertThatThrownBy(() -> client.push(build2Id, BuildPushParameters.builder().reimport(true).tagPrefix("test-tag").build())).hasCauseInstanceOf(ForbiddenException.class);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) ArtifactClient(org.jboss.pnc.client.ArtifactClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with ArtifactClient

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

the class BuildEndpointTest method shouldModifyBuiltArtifactQualityLevels.

@Test
public void shouldModifyBuiltArtifactQualityLevels() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = build3Id;
    String REASON = "This artifact has become old enough";
    ArtifactClient artifactClient = new ArtifactClient(RestClientConfiguration.asSystem());
    Artifact newArtifact = artifactClient.create(Artifact.builder().artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).filename("builtArtifactInsertNew.jar").identifier("integration-test:built-artifact-new:jar:1.0").targetRepository(artifactClient.getSpecific("100").getTargetRepository()).md5("insert-md5-22").sha1("insert-22").sha256("insert-22").size(10L).build());
    client.setBuiltArtifacts(build3Id, Collections.singletonList(newArtifact.getId()));
    client.createBuiltArtifactsQualityLevelRevisions(buildRecordId, "BLACKListed", REASON);
    RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
    for (Artifact artifact : artifacts) {
        assertThat(artifact.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
        assertThat(artifact.getQualityLevelReason()).isEqualTo(REASON);
        assertThat(artifact.getModificationUser().getUsername()).isEqualTo("system");
    }
    Build withAttribute = client.getSpecific(buildRecordId);
    assertThat(withAttribute.getAttributes()).contains(entry(Attributes.BLACKLIST_REASON, REASON));
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) 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