Search in sources :

Example 21 with ProductVersion

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

the class ProductEndpointTest method testGetProductVersions.

@Test
public void testGetProductVersions() throws ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<ProductVersion> all = client.getProductVersions(productId);
    assertThat(all).hasSize(2).allMatch(v -> v.getProduct().getId().equals(productId));
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) ProductVersion(org.jboss.pnc.dto.ProductVersion) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 22 with ProductVersion

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

the class SecondLevelCacheStoreTest method createProductVersionAndValidateResults.

public ProductVersion createProductVersionAndValidateResults(Product product, String version) throws ClientException {
    // given
    ProductVersion productVersion = ProductVersion.builder().product(product).version(version).build();
    // when
    ProductVersion created = productVersionClient.createNew(productVersion);
    // then
    assertThat(created.getId()).isNotEmpty();
    ProductVersion retrieved = productVersionClient.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);
    return retrieved;
}
Also used : ProductVersion(org.jboss.pnc.dto.ProductVersion)

Example 23 with ProductVersion

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

the class ProductVersionEndpointTest method shouldFailGracefullyOnNonExistentProduct.

@Test
public void shouldFailGracefullyOnNonExistentProduct() {
    // given
    String nonExistentProductId = "384583";
    ProductVersion productVersion = ProductVersion.builder().product(ProductRef.refBuilder().id(nonExistentProductId).build()).version("42.2").build();
    // whenthen
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    assertThatThrownBy(() -> client.createNew(productVersion)).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 24 with ProductVersion

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

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