Search in sources :

Example 1 with ProductVersion

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

the class GroupConfigurationEndpointTest method createProductVersion.

private ProductVersion createProductVersion() throws ClientException {
    ProductClient pClient = new ProductClient(RestClientConfiguration.asUser());
    Product product = pClient.getAll().iterator().next();
    ProductVersionClient pvClient = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion pv = ProductVersion.builder().version("3245.6742").product(ProductRef.refBuilder().id(product.getId()).build()).build();
    return pvClient.createNew(pv);
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient)

Example 2 with ProductVersion

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

the class ProductVersionEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
    product = productClient.getAll().iterator().next();
    Iterator<ProductVersion> it = productClient.getProductVersions(product.getId()).iterator();
    productVersionsId = it.next().getId();
    productVersionsId2 = it.next().getId();
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) ProductVersion(org.jboss.pnc.dto.ProductVersion) BeforeClass(org.junit.BeforeClass)

Example 3 with ProductVersion

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

the class ProductVersionEndpointTest method shouldNotUpdateGroupConfigsWithNonExistantGroupConfig.

@Test
public void shouldNotUpdateGroupConfigsWithNonExistantGroupConfig() throws ClientException {
    // given
    GroupConfigurationRef notExistingGC = GroupConfigurationRef.refBuilder().id("9999").name("i-dont-exist").build();
    Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
    // when
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    groupConfis.putAll(productVersion.getGroupConfigs());
    groupConfis.put(notExistingGC.getId(), notExistingGC);
    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)

Example 4 with ProductVersion

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

the class ProductVersionEndpointTest method testGetSpecific.

@Test
public void testGetSpecific() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    ProductVersion dto = client.getSpecific(productVersionsId);
    // from DatabaseDataInitializer
    assertThat(dto.getVersion()).isEqualTo("1.0");
    // from DatabaseDataInitializer
    assertThat(dto.getProduct().getId()).isEqualTo(product.getId());
}
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 5 with ProductVersion

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

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