Search in sources :

Example 6 with ProductData

use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.

the class DefaultEntitlementCertServiceAdapterTest method setupEntitlements.

private void setupEntitlements(String consumerArch, String certVersion) {
    consumer.setFact("system.certificate_version", certVersion);
    consumer.setFact("uname.machine", consumerArch);
    ProductData pdata = subscription.getProduct();
    pdata.setAttribute(Product.Attributes.WARNING_PERIOD, "20");
    pdata.setAttribute(Product.Attributes.SOCKETS, "4");
    pdata.setAttribute(Product.Attributes.RAM, "8");
    pdata.setAttribute(Product.Attributes.CORES, "4");
    pdata.setAttribute(Product.Attributes.MANAGEMENT_ENABLED, "true");
    pdata.setAttribute(Product.Attributes.STACKING_ID, "45678");
    entitlement.getPool().setAttribute(Product.Attributes.VIRT_ONLY, "true");
    pdata.setAttribute(Product.Attributes.SUPPORT_LEVEL, "slevel");
    pdata.setAttribute(Product.Attributes.SUPPORT_TYPE, "stype");
    subscription.setAccountNumber("account1");
    subscription.setContractNumber("contract1");
    subscription.setOrderNumber("order1");
    if (pdata.getProductContent() != null) {
        for (ProductContentData pcd : pdata.getProductContent()) {
            pcd.setEnabled(false);
        }
    }
}
Also used : ProductData(org.candlepin.model.dto.ProductData) ProductContentData(org.candlepin.model.dto.ProductContentData)

Example 7 with ProductData

use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.

the class TestUtil method createSubscription.

public static Subscription createSubscription(Owner owner, ProductData dto, Collection<ProductData> providedProductsData) {
    Set<ProductData> providedProductsSet = new HashSet<>();
    providedProductsSet.addAll(providedProductsData);
    Subscription sub = new Subscription(owner, dto, providedProductsSet, 1000L, createDate(2000, 1, 1), createDate(2050, 1, 1), createDate(2000, 1, 1));
    sub.setId("test-sub-" + randomInt());
    return sub;
}
Also used : ProductData(org.candlepin.model.dto.ProductData) SourceSubscription(org.candlepin.model.SourceSubscription) Subscription(org.candlepin.model.dto.Subscription) HashSet(java.util.HashSet)

Example 8 with ProductData

use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.

the class TestUtil method copyFromSub.

/**
 * Returns a pool which will look like it was created from the given subscription
 * during refresh pools.
 *
 * @param sub source subscription
 * @return pool for subscription
 */
public static Pool copyFromSub(Subscription sub) {
    Product product = createProduct((ProductData) sub.getProduct());
    Product derivedProduct = createProduct((ProductData) sub.getDerivedProduct());
    List<Product> providedProducts = new LinkedList<>();
    if (sub.getProvidedProducts() != null) {
        for (ProductData pdata : sub.getProvidedProducts()) {
            if (pdata != null) {
                providedProducts.add(TestUtil.createProduct(pdata));
            }
        }
    }
    List<Product> derivedProvidedProducts = new LinkedList<>();
    if (sub.getDerivedProvidedProducts() != null) {
        for (ProductData pdata : sub.getDerivedProvidedProducts()) {
            if (pdata != null) {
                derivedProvidedProducts.add(TestUtil.createProduct(pdata));
            }
        }
    }
    Pool pool = new Pool(sub.getOwner(), product, providedProducts, sub.getQuantity(), sub.getStartDate(), sub.getEndDate(), sub.getContractNumber(), sub.getAccountNumber(), sub.getOrderNumber());
    pool.setDerivedProduct(derivedProduct);
    pool.setDerivedProvidedProducts(derivedProvidedProducts);
    if (sub.getId() != null) {
        pool.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
    }
    pool.setUpstreamPoolId(sub.getUpstreamPoolId());
    pool.setUpstreamConsumerId(sub.getUpstreamConsumerId());
    pool.setUpstreamEntitlementId(sub.getUpstreamEntitlementId());
    for (Branding branding : sub.getBranding()) {
        pool.getBranding().add(new Branding(branding.getProductId(), branding.getType(), branding.getName()));
    }
    return pool;
}
Also used : ProductData(org.candlepin.model.dto.ProductData) SourceSubscription(org.candlepin.model.SourceSubscription) Product(org.candlepin.model.Product) ActivationKeyPool(org.candlepin.model.activationkeys.ActivationKeyPool) Pool(org.candlepin.model.Pool) Branding(org.candlepin.model.Branding) LinkedList(java.util.LinkedList)

Example 9 with ProductData

use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.

the class ProductDataTranslatorTest method initSourceObject.

@Override
protected ProductData initSourceObject() {
    ProductData source = new ProductData();
    Map<String, String> attributes = new HashMap<>();
    attributes.put("attrib_1", "attrib_value_1");
    attributes.put("attrib_2", "attrib_value_2");
    attributes.put("attrib_3", "attrib_value_3");
    Collection<String> depProdIds = new LinkedList<>();
    depProdIds.add("dep_prod_1");
    depProdIds.add("dep_prod_2");
    depProdIds.add("dep_prod_3");
    source.setUuid("test_uuid");
    source.setId("test_id");
    source.setName("test_name");
    source.setMultiplier(10L);
    source.setAttributes(attributes);
    source.setDependentProductIds(depProdIds);
    source.setLocked(true);
    for (int i = 0; i < 3; ++i) {
        Content content = TestUtil.createContent("content-" + i);
        content.setUuid(content.getId() + "_uuid");
        source.addContent(content, true);
    }
    return source;
}
Also used : ProductData(org.candlepin.model.dto.ProductData) HashMap(java.util.HashMap) Content(org.candlepin.model.Content) LinkedList(java.util.LinkedList)

Example 10 with ProductData

use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.

the class PoolManagerTest method derivedProvidedProductsCopiedOntoMasterPoolWhenCreatingNewPool.

@Test
public void derivedProvidedProductsCopiedOntoMasterPoolWhenCreatingNewPool() {
    Product product = TestUtil.createProduct();
    Product subProduct = TestUtil.createProduct();
    Product subProvidedProduct = TestUtil.createProduct();
    Subscription sub = TestUtil.createSubscription(owner, product);
    sub.setDerivedProduct(subProduct.toDTO());
    Set<ProductData> subProvided = new HashSet<>();
    subProvided.add(subProvidedProduct.toDTO());
    sub.setDerivedProvidedProducts(subProvided);
    this.mockProducts(owner, product, subProduct, subProvidedProduct);
    PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
    List<Pool> pools = pRules.createAndEnrichPools(sub);
    assertEquals(1, pools.size());
    Pool resultPool = pools.get(0);
    assertEquals(1, resultPool.getDerivedProvidedProducts().size());
}
Also used : ProductData(org.candlepin.model.dto.ProductData) PoolRules(org.candlepin.policy.js.pool.PoolRules) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Subscription(org.candlepin.model.dto.Subscription) SourceSubscription(org.candlepin.model.SourceSubscription) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ProductData (org.candlepin.model.dto.ProductData)30 Product (org.candlepin.model.Product)22 Pool (org.candlepin.model.Pool)13 Owner (org.candlepin.model.Owner)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)11 List (java.util.List)10 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)10 HashSet (java.util.HashSet)9 HashMap (java.util.HashMap)8 SourceSubscription (org.candlepin.model.SourceSubscription)8 Subscription (org.candlepin.model.dto.Subscription)8 Date (java.util.Date)7 Consumer (org.candlepin.model.Consumer)7 LinkedList (java.util.LinkedList)5 Content (org.candlepin.model.Content)5 ProductContentData (org.candlepin.model.dto.ProductContentData)5 AutobindData (org.candlepin.resource.dto.AutobindData)5 Map (java.util.Map)4 ContentData (org.candlepin.model.dto.ContentData)4