Search in sources :

Example 16 with GroupConfiguration

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());
}
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 17 with GroupConfiguration

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);
}
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 18 with GroupConfiguration

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);
}
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 19 with GroupConfiguration

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();
}
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)

Example 20 with GroupConfiguration

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"));
}
Also used : GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) ClientErrorException(javax.ws.rs.ClientErrorException) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)23 Test (org.junit.Test)21 ContainerTest (org.jboss.pnc.test.category.ContainerTest)18 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)6 HashMap (java.util.HashMap)5 GroupBuild (org.jboss.pnc.dto.GroupBuild)5 ProductVersion (org.jboss.pnc.dto.ProductVersion)5 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)4 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)4 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)4 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 GroupConfigurationPatchBuilder (org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder)2 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)2 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)2 Test (org.junit.jupiter.api.Test)2 Undertow (io.undertow.Undertow)1 Method (java.lang.reflect.Method)1 Path (java.nio.file.Path)1