use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method shouldPatchGroupConfiguration.
@Test
public void shouldPatchGroupConfiguration() throws ClientException, PatchBuilderException {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
GroupConfiguration groupConfiguration = client.getAll().iterator().next();
String id = groupConfiguration.getId();
ProductVersion newProductVersion = createProductVersion();
ProductVersion pv = ProductVersion.builder().id(newProductVersion.getId()).build();
GroupConfigurationPatchBuilder builder = new GroupConfigurationPatchBuilder().replaceProductVersion(pv);
GroupConfiguration updated = client.patch(id, builder);
assertThat(updated.getProductVersion().getVersion()).isEqualTo(newProductVersion.getVersion());
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testAddBuildConfig.
@Test
public void testAddBuildConfig() throws ClientException {
// with
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
String gcId = "100";
BuildConfiguration buildConfiguration = bcClient.getAll().iterator().next();
String bcToAddId = buildConfiguration.getId();
GroupConfiguration groupConfiguration = client.getSpecific(gcId);
assertThat(groupConfiguration.getBuildConfigs()).doesNotContainKey(bcToAddId);
// when
client.addBuildConfig(gcId, buildConfiguration);
// then
assertThat(client.getSpecific(gcId).getBuildConfigs()).containsKey(bcToAddId);
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method shouldUpdateAllBuildConfigurations.
@Test
public void shouldUpdateAllBuildConfigurations() throws Exception {
// with
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
String gcId = "101";
BuildConfiguration bc = bcClient.getAll().iterator().next();
GroupConfiguration gc = client.getSpecific(gcId);
String bcId = bc.getId();
Map<String, BuildConfigurationRef> buildConfigurationMap = new HashMap<>();
buildConfigurationMap.put(bcId, bc);
GroupConfiguration updated = gc.toBuilder().buildConfigs(buildConfigurationMap).build();
assertThat(gc.getBuildConfigs()).doesNotContainKey(bcId);
// when
client.update(gc.getId(), updated);
// then
assertThat(client.getSpecific(gcId).getBuildConfigs()).containsOnlyKeys(bcId);
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method shouldUpdateAllBuildConfigurationsWithEmptyList.
@Test
public void shouldUpdateAllBuildConfigurationsWithEmptyList() throws Exception {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
String gcId = "101";
GroupConfiguration gc = client.getSpecific(gcId);
GroupConfiguration updated = gc.toBuilder().buildConfigs(new HashMap<>()).build();
assertThat(gc.getBuildConfigs()).isNotEmpty();
// when
client.update(gc.getId(), updated);
// then
assertThat(client.getSpecific(gcId).getBuildConfigs()).isEmpty();
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testCreatingExistingConflicts.
@Test
public void testCreatingExistingConflicts() throws ClientException {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
String gcId = "100";
GroupConfiguration existing = client.getSpecific(gcId).toBuilder().id(null).build();
assertThatThrownBy(() -> client.createNew(existing)).hasCauseInstanceOf(ClientErrorException.class).has(new Condition<Throwable>((e -> ((ClientErrorException) e.getCause()).getResponse().getStatus() == 409), "Has Cause with conflicted status code 409"));
}
Aggregations