Search in sources :

Example 1 with GroupConfigurationPatchBuilder

use of org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder 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());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupConfigurationPatchBuilder(org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 2 with GroupConfigurationPatchBuilder

use of org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder 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());
}
Also used : GroupConfigurationPatchBuilder(org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)2 GroupConfigurationPatchBuilder (org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder)2 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)2 ContainerTest (org.jboss.pnc.test.category.ContainerTest)2 Test (org.junit.Test)2 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)1 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1