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);
}
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);
}
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
}
}
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));
}
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);
}
}
Aggregations