use of org.jboss.pnc.client.BuildClient 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.client.BuildClient in project pnc by project-ncl.
the class BuildEndpointTest method shouldGetAndRemoveAttribute.
@Test
public void shouldGetAndRemoveAttribute() throws ClientException {
// given
BuildClient client = new BuildClient(RestClientConfiguration.asUser());
Build original = client.getSpecific(buildId);
final String key = "TEST_ATTRIBUTE";
final String value = "test value";
assertThat(original.getAttributes()).doesNotContainKey(key);
// when
client.addAttribute(buildId, key, value);
// then
Build withAttribute = client.getSpecific(buildId);
assertThat(withAttribute.getAttributes()).contains(entry(key, value));
// and when
client.removeAttribute(buildId, key);
// then
Build withRemovedAttribute = client.getSpecific(buildId);
assertThat(withRemovedAttribute.getAttributes()).doesNotContainKey(key);
}
use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.
the class BuildEndpointTest method shouldNotApplyUnknownQualityLevel.
@Test
public void shouldNotApplyUnknownQualityLevel() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asUser());
String REASON = "This artifact will be marked as WHITELISTED";
assertThatThrownBy(() -> client.createBuiltArtifactsQualityLevelRevisions(buildId, "WHITELISTED", REASON)).hasCauseInstanceOf(BadRequestException.class);
}
use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterResults.
@Test
public void shouldFilterResults() throws Exception {
BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
String rsql = "id==" + buildId;
List<String> filtered = bc.getAll(null, null, Optional.empty(), Optional.of(rsql)).getAll().stream().map(BuildRef::getId).collect(Collectors.toList());
assertThat(filtered).containsExactly(buildId);
}
use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.
the class BuildPushTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
Iterator<Build> it = bc.getAll(null, null).iterator();
buildId = it.next().getId();
build2Id = it.next().getId();
}
Aggregations