use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactProviderTest method testUpdate.
@Test
public void testUpdate() {
fillRepository(artifacts);
Artifact toUpdate = Artifact.builder().id(artifact1.getId().toString()).artifactQuality(// Modified field
ArtifactQuality.BLACKLISTED).buildCategory(BuildCategory.STANDARD).identifier(artifact1.getIdentifier()).md5(artifact1.getMd5()).sha1(artifact1.getSha1()).sha256(artifact1.getSha256()).build();
// assert that original is
assertThat(artifact1.getArtifactQuality()).isNotEqualTo(ArtifactQuality.BLACKLISTED);
// different
Artifact updated = provider.update(Integer.toString(artifact1.getId()), toUpdate);
assertThat(updated.getId()).isEqualTo(artifact1.getId().toString());
// modified
assertThat(updated.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
assertThat(updated.getIdentifier()).isEqualTo(artifact1.getIdentifier());
assertThat(updated.getSha256()).isEqualTo(artifact1.getSha256());
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ArtifactProviderTest method testStore.
@Test
public void testStore() {
TargetRepository repo = TargetRepository.refBuilder().identifier("repo-id").repositoryPath("/repo/path").repositoryType(RepositoryType.MAVEN).build();
final String identifier = "foo:bar:0.0.1";
Artifact artifact = Artifact.builder().identifier(identifier).artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).build();
Artifact stored = provider.store(artifact);
assertThat(stored.getIdentifier()).isEqualTo(identifier);
assertThat(stored.getId()).isNotNull();
Mockito.verify(repository).save(ArgumentMatchers.argThat(a -> identifier.equals(a.getIdentifier())));
}
use of org.jboss.pnc.dto.Artifact in project bacon by project-ncl.
the class OfflineManifestGeneratorTest method mockBuildsAndArtifacts.
private void mockBuildsAndArtifacts() {
TargetRepository repository = TargetRepository.refBuilder().identifier("repo1").repositoryType(RepositoryType.MAVEN).build();
builds = new HashMap<>();
artifacts = new HashSet<>();
for (int i = 1; i <= 5; i++) {
String buildName = "build" + i;
List<Artifact> builtArtifacts = new ArrayList<>();
for (int j = 1; j <= i * 2; j++) {
builtArtifacts.add(Artifact.builder().targetRepository(repository).identifier("org:built:jar:" + i + "." + j).filename("built-" + i + "." + j + ".jar").sha256("built_" + i + "_" + j).build());
}
List<Artifact> dependencies = new ArrayList<>();
for (int k = 1; k <= i * 3; k++) {
dependencies.add(Artifact.builder().targetRepository(repository).identifier("org:dependency:jar:" + i + "." + k).filename("dependency-" + i + "." + k + ".jar").sha256("dependency_" + i + "_" + k).build());
}
PncBuild build = new PncBuild();
build.setId(buildName);
build.setName(buildName);
build.addBuiltArtifacts(builtArtifacts);
build.addDependencyArtifacts(dependencies);
builds.put(buildName, build);
artifacts.addAll(builtArtifacts);
artifacts.addAll(dependencies);
}
}
use of org.jboss.pnc.dto.Artifact 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));
}
use of org.jboss.pnc.dto.Artifact in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testGetDeliveredArtifacts.
@Test
public void testGetDeliveredArtifacts() throws ClientException {
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Artifact> all = client.getDeliveredArtifacts(milestoneId);
assertThat(all).hasSize(3);
}
Aggregations