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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations