Search in sources :

Example 6 with GroupConfigurationRef

use of org.jboss.pnc.dto.GroupConfigurationRef 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)

Example 7 with GroupConfigurationRef

use of org.jboss.pnc.dto.GroupConfigurationRef in project pnc by project-ncl.

the class ProductVersionEndpointTest method shouldNotUpdateGroupConfigsWhenOneIsAlreadyAsssociatedWithAnotherProductVersion.

@Test
public void shouldNotUpdateGroupConfigsWhenOneIsAlreadyAsssociatedWithAnotherProductVersion() throws ClientException {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    GroupConfigurationRef alreadyAssignedGC = client.getSpecific(productVersionsId).getGroupConfigs().values().iterator().next();
    Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
    assertThat(alreadyAssignedGC).isNotNull();
    // when
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    groupConfis.putAll(productVersion.getGroupConfigs());
    groupConfis.put(alreadyAssignedGC.getId(), alreadyAssignedGC);
    ProductVersion toUpdate = productVersion.toBuilder().groupConfigs(groupConfis).build();
    // then
    assertThatThrownBy(() -> client.update(productVersion.getId(), toUpdate)).isInstanceOf(ClientException.class);
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)7 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)6 ContainerTest (org.jboss.pnc.test.category.ContainerTest)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 ProductVersion (org.jboss.pnc.dto.ProductVersion)5 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)3 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)3 ClientException (org.jboss.pnc.client.ClientException)1 GroupBuild (org.jboss.pnc.dto.GroupBuild)1