use of org.jboss.pnc.client.ArtifactClient 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");
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsFilteredByIdentifier.
@Test
public void testGetAllArtifactsFilteredByIdentifier() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ArtifactInfo> result;
result = client.getAllFiltered("*demo:*:jar:*", null, null);
assertThat(result).allSatisfy(a -> assertThat(a.getIdentifier().contains("demo:") && a.getIdentifier().contains(":jar:")));
result = client.getAllFiltered("demo:built-artifact11:pom:*", null, null);
// from DatabaseDataInitializer
assertThat(result).hasSize(1);
result = client.getAllFiltered("demo:built-artifact22:jar:1.0", null, null);
// from DatabaseDataInitializer
assertThat(result).hasSize(1);
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method setTargetRepository.
@Before
public void setTargetRepository() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
List<Artifact> artifacts = new ArrayList<>();
for (Artifact artifact : client.getAll(null, null, null)) {
artifacts.add(artifact);
}
targetRepositoryRef = artifacts.get(0).getTargetRepository();
artifactRest1 = artifacts.get(0);
artifactRest2 = artifacts.get(1);
artifactRest3 = artifacts.get(4);
artifactRest4 = artifacts.get(6);
logger.debug("Using targetRepositoryRef: {}", targetRepositoryRef);
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetSpecificArtifact.
@Test
public void testGetSpecificArtifact() throws ClientException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
Artifact artifact = client.getSpecific(artifactRest1.getId());
assertThat(artifact.getId()).isEqualTo(artifactRest1.getId());
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldModifyModificationFields.
@Test
public void shouldModifyModificationFields() throws ClientException {
String id = artifactRest1.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
// Updating an audited property should create a new revision and should alter modificationUser and
// modificationTime. But, creationTime should never be updated, not creationUser
Artifact artifact = client.getSpecific(id);
Artifact updatedArtifact = artifact.toBuilder().modificationTime(Instant.now()).artifactQuality(ArtifactQuality.DEPRECATED).creationTime(Instant.now()).size(1000L).build();
client.update(id, updatedArtifact);
Artifact updatedArtifactDB = client.getSpecific(id);
assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(updatedArtifact.getArtifactQuality());
assertThat(updatedArtifactDB.getSize()).isEqualTo(updatedArtifact.getSize());
assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
assertThat(updatedArtifactDB.getCreationUser()).isEqualTo(artifact.getCreationUser());
assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(artifact.getModificationTime());
assertThat(updatedArtifactDB.getCreationTime()).isNotEqualTo(updatedArtifact.getCreationTime());
assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(updatedArtifact.getModificationTime());
}
Aggregations