Search in sources :

Example 21 with ProductDTO

use of org.candlepin.dto.manifest.v1.ProductDTO in project candlepin by candlepin.

the class OwnerProductResourceTest method testUpdateProductIdMismatch.

@Test(expected = BadRequestException.class)
public void testUpdateProductIdMismatch() {
    Owner owner = this.createOwner("Update-Product-Owner");
    ProductDTO pdto = this.buildTestProductDTO();
    ProductDTO product = this.ownerProductResource.createProduct(owner.getKey(), pdto);
    ProductDTO update = this.buildTestProductDTO();
    update.setId("TaylorSwift");
    ProductDTO result = this.ownerProductResource.updateProduct(owner.getKey(), product.getId(), update);
}
Also used : Owner(org.candlepin.model.Owner) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Example 22 with ProductDTO

use of org.candlepin.dto.manifest.v1.ProductDTO in project candlepin by candlepin.

the class OwnerProductResourceTest method buildTestProductDTO.

private ProductDTO buildTestProductDTO() {
    ProductDTO dto = TestUtil.createProductDTO("test_product");
    dto.setAttribute(Product.Attributes.VERSION, "1.0");
    dto.setAttribute(Product.Attributes.VARIANT, "server");
    dto.setAttribute(Product.Attributes.TYPE, "SVC");
    dto.setAttribute(Product.Attributes.ARCHITECTURE, "ALL");
    return dto;
}
Also used : ProductDTO(org.candlepin.dto.api.v1.ProductDTO)

Example 23 with ProductDTO

use of org.candlepin.dto.manifest.v1.ProductDTO in project candlepin by candlepin.

the class ProductResourceTest method buildTestProductDTO.

private ProductDTO buildTestProductDTO() {
    ProductDTO dto = TestUtil.createProductDTO("test_product");
    dto.setAttribute(Product.Attributes.VERSION, "1.0");
    dto.setAttribute(Product.Attributes.VARIANT, "server");
    dto.setAttribute(Product.Attributes.TYPE, "SVC");
    dto.setAttribute(Product.Attributes.ARCHITECTURE, "ALL");
    return dto;
}
Also used : ProductDTO(org.candlepin.dto.api.v1.ProductDTO)

Example 24 with ProductDTO

use of org.candlepin.dto.manifest.v1.ProductDTO in project candlepin by candlepin.

the class ProductResourceTest method testCreateProductResource.

@Test(expected = BadRequestException.class)
public void testCreateProductResource() {
    Owner owner = this.createOwner("Example-Corporation");
    ProductDTO dto = this.buildTestProductDTO();
    assertNull(this.ownerProductCurator.getProductById(owner.getKey(), dto.getId()));
    productResource.createProduct(dto);
}
Also used : Owner(org.candlepin.model.Owner) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Example 25 with ProductDTO

use of org.candlepin.dto.manifest.v1.ProductDTO in project candlepin by candlepin.

the class ProductResourceTest method testCreateProductWithContent.

@Test(expected = BadRequestException.class)
public void testCreateProductWithContent() {
    Owner owner = this.createOwner("Example-Corporation");
    ProductDTO pdto = this.buildTestProductDTO();
    ContentDTO cdto = TestUtil.createContentDTO();
    pdto.addContent(cdto, true);
    assertNull(this.ownerProductCurator.getProductById(owner.getKey(), pdto.getId()));
    ProductDTO result = productResource.createProduct(pdto);
    Product entity = this.ownerProductCurator.getProductById(owner.getKey(), pdto.getId());
    ProductDTO expected = this.modelTranslator.translate(entity, ProductDTO.class);
    assertNotNull(entity);
    assertEquals(expected, result);
    assertNotNull(result.getProductContent());
    assertEquals(1, result.getProductContent().size());
    assertEquals(cdto, result.getProductContent().iterator().next().getContent());
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Aggregations

ProductDTO (org.candlepin.dto.api.v1.ProductDTO)29 Product (org.candlepin.model.Product)27 Test (org.junit.Test)27 Owner (org.candlepin.model.Owner)25 ProductDTO (org.candlepin.dto.manifest.v1.ProductDTO)12 Content (org.candlepin.model.Content)10 ProductContent (org.candlepin.model.ProductContent)9 ContentDTO (org.candlepin.dto.api.v1.ContentDTO)7 Parameters (junitparams.Parameters)6 ContentDTO (org.candlepin.dto.manifest.v1.ContentDTO)6 Transactional (com.google.inject.persist.Transactional)5 Reader (java.io.Reader)5 StringReader (java.io.StringReader)4 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)4 Subscription (org.candlepin.model.dto.Subscription)4 Consumes (javax.ws.rs.Consumes)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ForbiddenException (org.candlepin.common.exceptions.ForbiddenException)3