Search in sources :

Example 11 with GroupConfigurationClient

use of org.jboss.pnc.client.GroupConfigurationClient 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)

Example 12 with GroupConfigurationClient

use of org.jboss.pnc.client.GroupConfigurationClient 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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) 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 13 with GroupConfigurationClient

use of org.jboss.pnc.client.GroupConfigurationClient 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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) HashMap(java.util.HashMap) 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 14 with GroupConfigurationClient

use of org.jboss.pnc.client.GroupConfigurationClient in project pnc by project-ncl.

the class GroupConfigurationEndpointTest method testGetGroupConfigs.

@Test
public void testGetGroupConfigs() throws RemoteResourceException {
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    assertThat(client.getAll()).isNotEmpty();
}
Also used : GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with GroupConfigurationClient

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

Aggregations

GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)16 ContainerTest (org.jboss.pnc.test.category.ContainerTest)16 Test (org.junit.Test)16 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)12 HashMap (java.util.HashMap)5 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)5 ProductVersion (org.jboss.pnc.dto.ProductVersion)4 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)3 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)3 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)3 GroupConfigurationPatchBuilder (org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder)2 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)2 ExecutorService (java.util.concurrent.ExecutorService)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 RemoteCollection (org.jboss.pnc.client.RemoteCollection)1 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)1 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)1