use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldNotCreateBuildConfigRevision.
@Test
public void shouldNotCreateBuildConfigRevision() throws ClientException {
String id = artifactRest1.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
Iterator<ArtifactRevision> itOriginal = client.getRevisions(id).iterator();
int numRevisionsOriginal = client.getRevisions(id).size();
// given latest revision
ArtifactRevision lastRevOriginal = itOriginal.next();
while (itOriginal.hasNext()) {
ArtifactRevision candidate = itOriginal.next();
if (candidate.getRev() > lastRevOriginal.getRev()) {
lastRevOriginal = candidate;
}
}
// Updating a not audited property should not create a new revision
Artifact artifact = client.getSpecific(id);
Artifact updatedArtifact = artifact.toBuilder().size(1000L).build();
client.update(id, updatedArtifact);
Iterator<ArtifactRevision> it = client.getRevisions(id).iterator();
int numRevisions = client.getRevisions(id).size();
// given latest revision
ArtifactRevision lastRev = it.next();
while (it.hasNext()) {
ArtifactRevision candidate = it.next();
if (candidate.getRev() > lastRev.getRev()) {
lastRev = candidate;
}
}
assertThat(numRevisionsOriginal).isEqualTo(numRevisions);
assertThat(lastRev.getRev()).isEqualTo(lastRevOriginal.getRev());
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldModifyQualityLevel.
@Test
public void shouldModifyQualityLevel() throws ClientException {
String id = artifactRest4.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asUser());
String REASON = "This artifact has become old enough";
Artifact artifact = client.getSpecific(id);
client.createQualityLevelRevision(id, "DEPrecated", REASON);
Artifact updatedArtifactDB = client.getSpecific(id);
assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(ArtifactQuality.DEPRECATED);
assertThat(updatedArtifactDB.getQualityLevelReason()).isEqualTo(REASON);
assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(artifact.getModificationTime());
assertThat(updatedArtifactDB.getModificationUser().getUsername()).isEqualTo("demo-user");
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsWithMd5AndSha256.
@Test
public void testGetAllArtifactsWithMd5AndSha256() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Artifact> artifacts = client.getAll(artifactRest1.getSha256(), artifactRest1.getMd5(), null);
assertThat(artifacts).hasSize(1).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest1.getId()));
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldFailToSaveArtifact.
@Test
public void shouldFailToSaveArtifact() {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asUser());
Artifact artifact = Artifact.builder().filename("builtArtifactInsert.jar").identifier("integration-test:built-artifact-insert:jar:1.0").targetRepository(targetRepositoryRef).buildCategory(BuildCategory.STANDARD).md5("insert-md5-1").sha1("insert-1").sha256("insert-1").build();
Exception caught = null;
try {
client.create(artifact);
} catch (ClientException e) {
caught = e;
}
Assertions.assertThat(caught).isNotNull();
Assertions.assertThat(caught.getCause()).isInstanceOf(javax.ws.rs.ForbiddenException.class);
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldDeleteTemporaryQualityLevel.
@Test
public void shouldDeleteTemporaryQualityLevel() throws ClientException {
Artifact artifact = Artifact.builder().artifactQuality(ArtifactQuality.TEMPORARY).buildCategory(BuildCategory.STANDARD).filename("temp-builtArtifactInsert3.jar").identifier("integration-test:temp-built-artifact-insert3:jar:1.0").targetRepository(targetRepositoryRef).md5("insert-md5-131").sha1("insert-131").sha256("insert-131").size(131L).build();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
Artifact inserted = client.create(artifact);
String id = inserted.getId();
Artifact retrieved = client.getSpecific(id);
Assertions.assertThat(retrieved.getArtifactQuality()).isEqualTo(ArtifactQuality.TEMPORARY);
String REASON = "This artifact can be nuked";
client.createQualityLevelRevision(id, "DELEted", REASON);
Artifact updatedArtifactDB = client.getSpecific(id);
assertThat(updatedArtifactDB.getId()).isEqualTo(retrieved.getId());
assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(ArtifactQuality.DELETED);
assertThat(updatedArtifactDB.getQualityLevelReason()).isEqualTo(REASON);
assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(retrieved.getCreationTime());
assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(retrieved.getModificationTime());
assertThat(updatedArtifactDB.getModificationUser().getUsername()).isEqualTo("system");
}
Aggregations