Search in sources :

Example 16 with ProductVersion

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

the class ProductVersionEndpointTest method testCreateNew.

@Test
public void testCreateNew() throws ClientException {
    // given
    ProductVersion productVersion = ProductVersion.builder().product(product).version("42.0").build();
    // when
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion created = client.createNew(productVersion);
    // then
    assertThat(created.getId()).isNotEmpty();
    ProductVersion retrieved = client.getSpecific(created.getId());
    ProductVersion toCompare = productVersion.toBuilder().productMilestones(// query had null, but server responds with empty map
    Collections.emptyMap()).productReleases(// query had null, but server responds with empty map
    Collections.emptyMap()).groupConfigs(// query had null, but server responds with empty map
    Collections.emptyMap()).buildConfigs(// query had null, but server responds with empty map
    Collections.emptyMap()).build();
    assertThat(created.getProduct().getId()).isEqualTo(toCompare.getProduct().getId());
    assertThat(created).isEqualToIgnoringGivenFields(toCompare, "id", "product", "attributes");
    assertThat(retrieved).isEqualTo(created);
}
Also used : ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 17 with ProductVersion

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

the class ProductVersionEndpointTest method shouldNotUpdateWithClosedMilestone.

@Test
public void shouldNotUpdateWithClosedMilestone() throws ClientException {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    // has closed milestone, from
    ProductVersion productVersion = client.getSpecific(productVersionsId);
    // DatabaseDataInitializer
    // when
    ProductVersion toUpdate = productVersion.toBuilder().version("2.0").build();
    // then
    assertThatThrownBy(() -> client.update(productVersion.getId(), toUpdate)).isInstanceOf(ClientException.class);
}
Also used : ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 18 with ProductVersion

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

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

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

Aggregations

ProductVersion (org.jboss.pnc.dto.ProductVersion)24 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)17 ContainerTest (org.jboss.pnc.test.category.ContainerTest)16 Test (org.junit.Test)16 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)5 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)5 HashMap (java.util.HashMap)4 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)4 ProductClient (org.jboss.pnc.client.ProductClient)4 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)3 Product (org.jboss.pnc.dto.Product)3 ClientException (org.jboss.pnc.client.ClientException)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)2 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Instant (java.time.Instant)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1