use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method shouldDeleteBuildConfigWithPatch.
@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
// given
GroupConfigurationClient groupConfigurationClient = new GroupConfigurationClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
GroupConfiguration gc = groupConfigurationClient.getAll().iterator().next();
assertThat(gc.getBuildConfigs()).isNotEmpty();
BuildConfiguration toRemove = bcClient.getSpecific(gc.getBuildConfigs().keySet().iterator().next());
GroupConfigurationPatchBuilder builder = new GroupConfigurationPatchBuilder();
builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
// when
groupConfigurationClient.patch(gc.getId(), builder);
// then
GroupConfiguration refresh = groupConfigurationClient.getSpecific(gc.getId());
assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldDeleteBuildConfigWithPatch.
@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
// given
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
ProductVersion productVersion = client.getSpecific(productVersionsId2);
assertThat(productVersion.getBuildConfigs()).isNotEmpty();
BuildConfiguration toRemove = bcClient.getSpecific(productVersion.getBuildConfigs().keySet().iterator().next());
ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
// when
client.patch(productVersion.getId(), builder);
// then
ProductVersion refresh = client.getSpecific(productVersionsId2);
assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class AdvancedBuildConfigurationClient method fallbackSupplier.
/**
* Used to retrieve build through through REST when WS Client loses connection and reconnects
*
* @param bcId Id of the BuildConfig where the build was run
* @return
* @throws RemoteResourceException
*/
private Build fallbackSupplier(String bcId) throws RemoteResourceException {
BuildsFilterParameters parameters = new BuildsFilterParameters();
parameters.setLatest(true);
Build build = null;
try (BuildConfigurationClient client = new BuildConfigurationClient(configuration)) {
build = client.getBuilds(bcId, parameters).iterator().next();
}
return build;
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldNotUpdateWhenEnvironmentDoesNotExist.
@Test
public void shouldNotUpdateWhenEnvironmentDoesNotExist() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration origBC = client.getSpecific(configurationId);
BuildConfiguration updateBC = origBC.toBuilder().environment(Environment.builder().id("10000").build()).build();
assertThatThrownBy(() -> client.update(configurationId, updateBC)).hasCauseInstanceOf(NotFoundException.class);
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevisions.
@Test
public void shouldGetBuildConfigurationRevisions() throws Exception {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
RemoteCollection<BuildConfigurationRevision> revisions = client.getRevisions(configurationId);
assertThat(revisions).anySatisfy(config -> assertThat(config.getId()).isEqualTo(configurationId));
}
Aggregations