Search in sources :

Example 1 with Product

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

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

the class ProductEndpointTest method testCreateNew.

@Test
@InSequence(20)
public void testCreateNew() throws ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product product = Product.builder().name("New Product").abbreviation("NP").description("The newst product of them all").productVersions(Collections.emptyMap()).build();
    Product created = client.createNew(product);
    assertThat(created.getId()).isNotEmpty();
    Product retrieved = client.getSpecific(created.getId());
    assertThat(created).isEqualToIgnoringGivenFields(product, "id");
    assertThat(retrieved).isEqualToIgnoringGivenFields(product, "id");
    assertThat(retrieved).isEqualTo(created);
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 3 with Product

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

the class ProductEndpointTest method shouldFailToAddConflictingProduct.

@Test
@InSequence(30)
public void shouldFailToAddConflictingProduct() throws URISyntaxException, ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product product = Product.builder().name("The Same Thing").abbreviation("TST").description("Let's keep doing the same thing over and over. Nobody will notice.").build();
    Product created = client.createNew(product);
    assertThat(created.getId()).isNotEmpty();
    try {
        client.createNew(product);
        fail("Exception should be thrown");
    } catch (ClientException ex) {
    // OK
    }
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ClientException(org.jboss.pnc.client.ClientException) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 4 with Product

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

the class RestTest method shouldUpdateProduct.

@Test
@InSequence(8)
public void shouldUpdateProduct() throws Exception {
    Product product = givenCommonSettingAnd().when().get(PRODUCT_REST_ENDPOINT + newProductId).then().statusCode(200).extract().as(Product.class);
    assertThat(product.getId()).isEqualTo(newProductId);
    // from product.json
    assertThat(product.getName()).isEqualTo("JBoss Enterprise Application Platform 6");
    String newName = "JBoss Enterprise Application Platform 7";
    product = product.toBuilder().name(newName).build();
    givenCommonSettingAnd().body(JsonUtils.toJson(product)).contentType(ContentType.JSON).when().put(PRODUCT_REST_ENDPOINT + newProductId).then().statusCode(204);
    // Reading updated resource
    givenCommonSettingAnd().when().get(PRODUCT_REST_ENDPOINT + newProductId).then().statusCode(200).body("id", equalTo(newProductId)).body("name", equalTo(newName));
}
Also used : Product(org.jboss.pnc.dto.Product) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with Product

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

the class PncEntitiesImporter method generateProduct.

private Product generateProduct() {
    ProductConfig productConfig = pigConfiguration.getProduct();
    Product product = Product.builder().name(productConfig.getName()).abbreviation(productConfig.getAbbreviation()).build();
    try {
        return productClient.createNew(product);
    } catch (ClientException e) {
        throw new RuntimeException("Failed to create the product", e);
    }
}
Also used : ProductConfig(org.jboss.pnc.bacon.pig.impl.config.ProductConfig) Product(org.jboss.pnc.dto.Product) ClientException(org.jboss.pnc.client.ClientException)

Aggregations

Product (org.jboss.pnc.dto.Product)17 ProductClient (org.jboss.pnc.client.ProductClient)10 ContainerTest (org.jboss.pnc.test.category.ContainerTest)9 Test (org.junit.Test)9 AbstractTest (org.jboss.pnc.bacon.test.AbstractTest)5 Order (org.junit.jupiter.api.Order)5 Test (org.junit.jupiter.api.Test)5 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 InSequence (org.jboss.arquillian.junit.InSequence)4 ClientException (org.jboss.pnc.client.ClientException)4 ProductVersion (org.jboss.pnc.dto.ProductVersion)3 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)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 Optional (java.util.Optional)1 BadRequestException (javax.ws.rs.BadRequestException)1