Search in sources :

Example 66 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class TestUtil method createContent.

public static Content createContent(ContentDTO dto) {
    Content content = null;
    if (dto != null) {
        content = createContent(dto.getId(), dto.getName());
        content.setUuid(dto.getUuid());
        content.setType(dto.getType());
        content.setLabel(dto.getLabel());
        content.setVendor(dto.getVendor());
        content.setContentUrl(dto.getContentUrl());
        content.setRequiredTags(dto.getRequiredTags());
        content.setReleaseVersion(dto.getReleaseVersion());
        content.setGpgUrl(dto.getGpgUrl());
        content.setMetadataExpire(dto.getMetadataExpiration());
        content.setModifiedProductIds(dto.getModifiedProductIds());
        content.setArches(dto.getArches());
        content.setLocked(dto.isLocked());
    }
    return content;
}
Also used : Content(org.candlepin.model.Content)

Example 67 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class TestUtil method createProduct.

public static Product createProduct(ProductDTO dto) {
    Product product = null;
    if (dto != null) {
        product = new Product(dto.getId(), dto.getName());
        product.setUuid(dto.getUuid());
        product.setMultiplier(dto.getMultiplier());
        product.setAttributes(dto.getAttributes());
        if (dto.getProductContent() != null) {
            for (ProductContentDTO pcd : dto.getProductContent()) {
                if (pcd != null) {
                    Content content = createContent((ContentDTO) pcd.getContent());
                    if (content != null) {
                        product.addContent(content, pcd.isEnabled() != null ? pcd.isEnabled() : true);
                    }
                }
            }
        }
        product.setDependentProductIds(dto.getDependentProductIds());
        product.setLocked(dto.isLocked() != null ? dto.isLocked() : false);
    }
    return product;
}
Also used : Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) ProductContentDTO(org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)

Example 68 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class TestUtil method createContent.

public static Content createContent(String id, String name) {
    Content content = new Content(id, name, "test-type", "test-label", "test-vendor");
    content.setContentUrl("https://test.url.com");
    content.setGpgUrl("https://gpg.test.url.com");
    content.setArches("x86");
    return content;
}
Also used : Content(org.candlepin.model.Content)

Example 69 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class TestUtil method createProduct.

public static Product createProduct(ProductData pdata) {
    Product product = null;
    if (pdata != null) {
        product = new Product(pdata.getId(), pdata.getName());
        product.setUuid(pdata.getUuid());
        product.setMultiplier(pdata.getMultiplier());
        product.setAttributes(pdata.getAttributes());
        if (pdata.getProductContent() != null) {
            for (ProductContentData pcd : pdata.getProductContent()) {
                if (pcd != null) {
                    Content content = createContent((ContentData) pcd.getContent());
                    if (content != null) {
                        product.addContent(content, pcd.isEnabled() != null ? pcd.isEnabled() : true);
                    }
                }
            }
        }
        product.setDependentProductIds(pdata.getDependentProductIds());
        product.setLocked(pdata.isLocked() != null ? pdata.isLocked() : false);
    }
    return product;
}
Also used : Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) ProductContentData(org.candlepin.model.dto.ProductContentData)

Example 70 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class EntitlementCertificateGeneratorTest method generateEntitlements.

/**
 * Generates some entitlements and the necessary objects for testing entitlement regeneration
 *
 * @return
 *  A list of entitlements
 */
private List<Entitlement> generateEntitlements() {
    Owner owner = TestUtil.createOwner("test-owner", "Test Owner");
    Content c1 = TestUtil.createContent("c1");
    Content c2 = TestUtil.createContent("c2");
    Content c3 = TestUtil.createContent("c3");
    Product prod1 = TestUtil.createProduct();
    Product prod2 = TestUtil.createProduct();
    Product prod3 = TestUtil.createProduct();
    Product pprod1 = TestUtil.createProduct();
    Product pprod2 = TestUtil.createProduct();
    Product pprod3 = TestUtil.createProduct();
    prod1.addContent(c1, true);
    pprod2.addContent(c2, true);
    prod3.addContent(c3, true);
    Pool pool1 = createPool(owner, prod1, Collections.singleton(pprod1), 1);
    Pool pool2 = createPool(owner, prod2, Collections.singleton(pprod2), 1);
    Pool pool3 = createPool(owner, prod3, Collections.singleton(pprod3), 1);
    Consumer consumer = TestUtil.createConsumer(owner);
    Entitlement ent1 = TestUtil.createEntitlement(owner, consumer, pool1, null);
    Entitlement ent2 = TestUtil.createEntitlement(owner, consumer, pool2, null);
    Entitlement ent3 = TestUtil.createEntitlement(owner, consumer, pool3, null);
    ent1.setId("ent1");
    ent2.setId("ent2");
    ent3.setId("ent3");
    return Arrays.asList(ent1, ent2, ent3);
}
Also used : Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Entitlement(org.candlepin.model.Entitlement)

Aggregations

Content (org.candlepin.model.Content)97 Test (org.junit.Test)45 ProductContent (org.candlepin.model.ProductContent)41 Product (org.candlepin.model.Product)40 Owner (org.candlepin.model.Owner)39 ContentDTO (org.candlepin.dto.api.v1.ContentDTO)25 HashMap (java.util.HashMap)18 EnvironmentContent (org.candlepin.model.EnvironmentContent)17 HashSet (java.util.HashSet)14 LinkedList (java.util.LinkedList)11 ProductDTO (org.candlepin.dto.api.v1.ProductDTO)10 ArrayList (java.util.ArrayList)9 Matchers.anyString (org.mockito.Matchers.anyString)9 Transactional (com.google.inject.persist.Transactional)8 Produces (javax.ws.rs.Produces)8 Parameters (junitparams.Parameters)8 ApiOperation (io.swagger.annotations.ApiOperation)7 ForbiddenException (org.candlepin.common.exceptions.ForbiddenException)7 Path (javax.ws.rs.Path)6 ProductContentDTO (org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)6