Search in sources :

Example 46 with ProductDTO

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

the class OwnerProductResourceTest method testCreateProductResource.

@Test
public void testCreateProductResource() {
    Owner owner = this.createOwner("Example-Corporation");
    ProductDTO pdto = this.buildTestProductDTO();
    assertNull(this.ownerProductCurator.getProductById(owner.getKey(), pdto.getId()));
    ProductDTO result = this.ownerProductResource.createProduct(owner.getKey(), pdto);
    Product entity = this.ownerProductCurator.getProductById(owner, pdto.getId());
    ProductDTO expected = this.modelTranslator.translate(entity, ProductDTO.class);
    assertNotNull(result);
    assertNotNull(entity);
    assertEquals(expected, result);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Example 47 with ProductDTO

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

the class OwnerProductResourceTest method getProduct.

@Test
public void getProduct() {
    Owner owner = this.createOwner("Example-Corporation");
    Product entity = this.createProduct("test_product", "test_product", owner);
    securityInterceptor.enable();
    ProductDTO result = this.ownerProductResource.getProduct(owner.getKey(), entity.getId());
    ProductDTO expected = this.modelTranslator.translate(entity, ProductDTO.class);
    assertNotNull(result);
    assertEquals(expected, result);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Example 48 with ProductDTO

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

the class ProductResourceTest method getProduct.

@Test
public void getProduct() {
    Owner owner = this.createOwner("Example-Corporation");
    Product entity = this.createProduct("test_product", "test_product", owner);
    ProductDTO expected = this.modelTranslator.translate(entity, ProductDTO.class);
    if (entity.isLocked()) {
        throw new RuntimeException("entity is locked...?");
    }
    securityInterceptor.enable();
    ProductDTO result = productResource.getProduct(entity.getUuid());
    assertNotNull(result);
    assertEquals(result, expected);
}
Also used : 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)28 Test (org.junit.Test)27 Owner (org.candlepin.model.Owner)25 Content (org.candlepin.model.Content)15 ProductContent (org.candlepin.model.ProductContent)13 ProductDTO (org.candlepin.dto.manifest.v1.ProductDTO)12 ContentDTO (org.candlepin.dto.api.v1.ContentDTO)11 ProductContentDTO (org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)7 Parameters (junitparams.Parameters)6 Transactional (com.google.inject.persist.Transactional)5 Reader (java.io.Reader)5 LinkedList (java.util.LinkedList)5 ContentDTO (org.candlepin.dto.manifest.v1.ContentDTO)5 StringReader (java.io.StringReader)4 HashSet (java.util.HashSet)4 Subscription (org.candlepin.model.dto.Subscription)4 HashMap (java.util.HashMap)3 Consumes (javax.ws.rs.Consumes)3 Path (javax.ws.rs.Path)3