use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldNotModifyCreationModificationFields.
@Test
public void shouldNotModifyCreationModificationFields() throws ClientException {
String id = artifactRest3.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
// Updating a not audited property should not create a new revision and should not alter modificationUser and
// modificationTime. Also, creationTime should never be updated, not creationUser
Artifact artifact = client.getSpecific(id);
Artifact updatedArtifact = artifact.toBuilder().modificationTime(Instant.now()).md5("md5").creationTime(Instant.now()).size(1000L).build();
client.update(id, updatedArtifact);
Artifact updatedArtifactDB = client.getSpecific(id);
assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
assertThat(updatedArtifactDB.getMd5()).isEqualTo(updatedArtifact.getMd5());
assertThat(updatedArtifactDB.getSize()).isEqualTo(updatedArtifact.getSize());
assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
assertThat(updatedArtifactDB.getCreationUser()).isEqualTo(artifact.getCreationUser());
assertThat(updatedArtifactDB.getModificationTime()).isEqualTo(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 BuildEndpointTest method shouldSetBuiltArtifacts.
@Test
public void shouldSetBuiltArtifacts() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
String buildRecordId = buildId;
RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
Set<Integer> artifactIds = artifactIds(artifacts);
assertThat(artifactIds).containsExactlyInAnyOrder(100, 101);
client.setBuiltArtifacts(buildRecordId, Collections.singletonList("104"));
RemoteCollection<Artifact> newBuiltArtifacts = client.getBuiltArtifacts(buildRecordId);
Set<Integer> updatedArtifactIds = artifactIds(newBuiltArtifacts);
assertThat(updatedArtifactIds).containsExactlyInAnyOrder(104);
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class BuildEndpointTest method shouldSetDependentArtifacts.
@Test
public void shouldSetDependentArtifacts() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
String buildRecordId = buildId;
RemoteCollection<Artifact> artifacts = client.getDependencyArtifacts(buildRecordId);
Set<Integer> artifactIds = artifactIds(artifacts);
assertThat(artifactIds).contains(104, 105);
client.setDependentArtifacts(buildRecordId, Collections.singletonList("102"));
RemoteCollection<Artifact> newDependencyArtifacts = client.getDependencyArtifacts(buildRecordId);
Set<Integer> updatedArtifactIds = artifactIds(newDependencyArtifacts);
assertThat(updatedArtifactIds).contains(102);
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactProviderTest method testStoreWithId.
@Test
public void testStoreWithId() {
final String identifier = "foo:bar:0.0.1";
Artifact artifact = Artifact.builder().id("123").identifier(identifier).artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).build();
try {
provider.store(artifact);
fail("Validation exception expected");
} catch (DTOValidationException ex) {
// ok
}
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactProviderTest method testGetSpecific.
@Test
public void testGetSpecific() {
fillRepository(artifacts);
Artifact specific = provider.getSpecific(Integer.toString(artifact1.getId()));
assertThat(specific.getId()).isEqualTo(artifact1.getId().toString());
assertThat(specific.getIdentifier()).isEqualTo(artifact1.getIdentifier());
assertThat(specific.getSha256()).isEqualTo(artifact1.getSha256());
}
Aggregations