Search in sources :

Example 6 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration 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 7 with GroupConfiguration

use of org.jboss.pnc.dto.GroupConfiguration 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 8 with GroupConfiguration

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

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

the class ProductVersionEndpointTest method testGetGroupConfigurations.

@Test
public void testGetGroupConfigurations() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<GroupConfiguration> all = client.getGroupConfigs(productVersionsId);
    assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
Also used : GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with GroupConfiguration

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

the class PncBuilderTest method getCountOfBuildConfigsForGroupBuild.

@Test
void getCountOfBuildConfigsForGroupBuild() throws Exception {
    Map<String, BuildConfigurationRef> buildConfigurations = new HashMap<>();
    BuildConfigurationRef bc1 = easyRandom.nextObject(BuildConfigurationRef.class);
    BuildConfigurationRef bc2 = easyRandom.nextObject(BuildConfigurationRef.class);
    BuildConfigurationRef bc3 = easyRandom.nextObject(BuildConfigurationRef.class);
    buildConfigurations.put(bc1.getName(), bc1);
    buildConfigurations.put(bc2.getName(), bc2);
    buildConfigurations.put(bc3.getName(), bc3);
    String groupConfigurationId = "5";
    String groupBuildId = "1";
    GroupConfiguration gc = GroupConfiguration.builder().id(groupConfigurationId).buildConfigs(buildConfigurations).build();
    GroupBuild gb = GroupBuild.builder().id(groupBuildId).groupConfig(gc).build();
    when(groupBuildClient.getSpecific(groupBuildId)).thenReturn(gb);
    when(groupConfigurationClient.getBuildConfigs(groupConfigurationId)).thenReturn(new RemoteCollection<BuildConfiguration>() {

        @Override
        public int size() {
            return buildConfigurations.size();
        }

        @Override
        public Collection<BuildConfiguration> getAll() {
            return null;
        }

        @Override
        public Iterator<BuildConfiguration> iterator() {
            return null;
        }
    });
    try (PncBuilder builder = new PncBuilder(groupBuildClient, groupConfigurationClient)) {
        assertEquals(buildConfigurations.size(), builder.getCountOfBuildConfigsForGroupBuild(groupBuildId));
    }
}
Also used : BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) GroupBuild(org.jboss.pnc.dto.GroupBuild) Iterator(java.util.Iterator) Collection(java.util.Collection) RemoteCollection(org.jboss.pnc.client.RemoteCollection) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Test(org.junit.jupiter.api.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