use of org.jboss.pnc.dto.Artifact 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.dto.Artifact 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.dto.Artifact 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());
}
use of org.jboss.pnc.dto.Artifact 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.dto.Artifact 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);
}
Aggregations