Search in sources :

Example 6 with GroupConfigurationClient

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

the class GroupConfigurationEndpointTest method testRemoveBuildConfigFromGroupConfig.

@Test
public void testRemoveBuildConfigFromGroupConfig() throws ClientException {
    // with
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "100";
    BuildConfiguration configuration = client.getBuildConfigs(gcId).iterator().next();
    // when
    client.removeBuildConfig(gcId, configuration.getId());
    // then
    GroupConfiguration refreshed = client.getSpecific(gcId);
    assertThat(refreshed).isNotNull();
    assertThat(refreshed.getBuildConfigs()).doesNotContainKey(configuration.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with GroupConfigurationClient

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

the class GroupConfigurationEndpointTest method getBuildConfigs.

@Test
public void getBuildConfigs() throws ClientException {
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "100";
    Set<String> bcIds = client.getSpecific(gcId).getBuildConfigs().keySet();
    assertThat(client.getBuildConfigs(gcId)).hasSameSizeAs(bcIds).allSatisfy(bc -> bcIds.contains(bc.getId()));
}
Also used : GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 8 with GroupConfigurationClient

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

the class ProductVersionEndpointTest method shouldUpdateGroupConfigsUsingPatch.

@Test
public void shouldUpdateGroupConfigsUsingPatch() throws PatchBuilderException, RemoteResourceException {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    GroupConfiguration gc = GroupConfiguration.builder().name("GC patch test").build();
    GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gcToAdd = gcc.createNew(gc);
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    Map<String, GroupConfigurationRef> groupConfigs = productVersion.getGroupConfigs();
    // when
    ProductVersionPatchBuilder patchBuilder = new ProductVersionPatchBuilder();
    ProductVersionPatchBuilder patch = patchBuilder.addGroupConfigs(Collections.singletonMap(gcToAdd.getId(), gcToAdd));
    client.patch(productVersionsId2, patch);
    // then
    groupConfigs.put(gcToAdd.getId(), gcToAdd);
    ProductVersion productVersionUpdated = client.getSpecific(productVersionsId2);
    assertThat(productVersionUpdated.getGroupConfigs()).containsKeys(groupConfigs.keySet().toArray(new String[groupConfigs.keySet().size()]));
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionPatchBuilder(org.jboss.pnc.client.patch.ProductVersionPatchBuilder) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 9 with GroupConfigurationClient

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

the class ProductVersionEndpointTest method shouldAdd2GroupConfigsWithPatch.

@Test
public void shouldAdd2GroupConfigsWithPatch() throws Exception {
    // given #1
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    GroupConfigurationClient gcClient = new GroupConfigurationClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    GroupConfiguration toAdd = gcClient.createNew(GroupConfiguration.builder().name("New GC1").build());
    ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
    Map<String, GroupConfigurationRef> toAddMap = new HashMap<>();
    toAddMap.put(toAdd.getId(), toAdd);
    builder.addGroupConfigs(toAddMap);
    // when #1
    client.patch(productVersion.getId(), builder);
    // then #1
    ProductVersion refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getGroupConfigs()).containsKey(toAdd.getId());
    // given #2 add second GC
    GroupConfiguration toAdd2 = gcClient.createNew(GroupConfiguration.builder().name("New GC2").build());
    builder = new ProductVersionPatchBuilder();
    toAddMap.clear();
    toAddMap.put(toAdd2.getId(), toAdd2);
    builder.addGroupConfigs(toAddMap);
    // when #2
    client.patch(productVersion.getId(), builder);
    // then #2
    refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getGroupConfigs()).containsKey(toAdd2.getId()).containsKey(toAdd.getId());
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) ProductVersion(org.jboss.pnc.dto.ProductVersion) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersionPatchBuilder(org.jboss.pnc.client.patch.ProductVersionPatchBuilder) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with GroupConfigurationClient

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

the class ProductVersionEndpointTest method shouldUpdateGroupConfigs.

@Test
public void shouldUpdateGroupConfigs() throws ClientException {
    // given
    GroupConfiguration gc = GroupConfiguration.builder().name("New GC").build();
    GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gcToAdd = gcc.createNew(gc);
    Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
    // when
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    groupConfis.putAll(productVersion.getGroupConfigs());
    groupConfis.put(gcToAdd.getId(), gcToAdd);
    ProductVersion toUpdate = productVersion.toBuilder().groupConfigs(groupConfis).build();
    client.update(productVersion.getId(), toUpdate);
    ProductVersion retrieved = client.getSpecific(productVersion.getId());
    // then
    assertThat(retrieved.getGroupConfigs()).hasSameSizeAs(groupConfis).containsKey(gcToAdd.getId());
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) 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