Search in sources :

Example 6 with Branding

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

the class PoolTranslatorTest method verifyOutput.

@Override
protected void verifyOutput(Pool source, PoolDTO dest, boolean childrenGenerated) {
    if (source != null) {
        assertEquals(source.getId(), dest.getId());
        assertEquals(source.getType().toString(), dest.getType());
        assertEquals(source.getActiveSubscription(), dest.isActiveSubscription());
        assertEquals(source.isCreatedByShare(), dest.isCreatedByShare());
        assertEquals(source.hasSharedAncestor(), dest.hasSharedAncestor());
        assertEquals(source.getQuantity(), dest.getQuantity());
        assertEquals(source.getStartDate(), dest.getStartDate());
        assertEquals(source.getEndDate(), dest.getEndDate());
        assertEquals(source.getAttributes(), dest.getAttributes());
        assertEquals(source.getRestrictedToUsername(), dest.getRestrictedToUsername());
        assertEquals(source.getContractNumber(), dest.getContractNumber());
        assertEquals(source.getAccountNumber(), dest.getAccountNumber());
        assertEquals(source.getOrderNumber(), dest.getOrderNumber());
        assertEquals(source.getConsumed(), dest.getConsumed());
        assertEquals(source.getExported(), dest.getExported());
        assertEquals(source.getShared(), dest.getShared());
        assertEquals(source.getCalculatedAttributes(), dest.getCalculatedAttributes());
        assertEquals(source.getUpstreamPoolId(), dest.getUpstreamPoolId());
        assertEquals(source.getUpstreamEntitlementId(), dest.getUpstreamEntitlementId());
        assertEquals(source.getUpstreamConsumerId(), dest.getUpstreamConsumerId());
        assertEquals(source.getProductName(), dest.getProductName());
        assertEquals(source.getProductId(), dest.getProductId());
        assertEquals(source.getProductAttributes(), dest.getProductAttributes());
        assertEquals(source.getStackId(), dest.getStackId());
        assertEquals(source.isStacked(), dest.isStacked());
        assertEquals(source.isDevelopmentPool(), dest.isDevelopmentPool());
        assertEquals(source.getDerivedProductAttributes(), dest.getDerivedProductAttributes());
        assertEquals(source.getDerivedProductId(), dest.getDerivedProductId());
        assertEquals(source.getDerivedProductName(), dest.getDerivedProductName());
        assertEquals(source.getSourceStackId(), dest.getSourceStackId());
        assertEquals(source.getSubscriptionSubKey(), dest.getSubscriptionSubKey());
        assertEquals(source.getSubscriptionId(), dest.getSubscriptionId());
        if (childrenGenerated) {
            this.ownerTranslatorTest.verifyOutput(source.getOwner(), dest.getOwner(), true);
            this.certificateTranslatorTest.verifyOutput(source.getCertificate(), dest.getCertificate(), true);
            Entitlement sourceSourceEntitlement = source.getSourceEntitlement();
            EntitlementDTO destSourceEntitlement = dest.getSourceEntitlement();
            if (sourceSourceEntitlement != null) {
                assertEquals(sourceSourceEntitlement.getId(), destSourceEntitlement.getId());
            } else {
                assertNull(destSourceEntitlement);
            }
            for (Branding brandingSource : source.getBranding()) {
                for (BrandingDTO brandingDTO : dest.getBranding()) {
                    assertNotNull(brandingDTO);
                    assertNotNull(brandingDTO.getProductId());
                    if (brandingDTO.getProductId().equals(brandingSource.getProductId())) {
                        this.brandingTranslatorTest.verifyOutput(brandingSource, brandingDTO, true);
                    }
                }
            }
            Set<Product> sourceProducts = source.getProvidedProducts();
            Set<PoolDTO.ProvidedProductDTO> productsDTO = dest.getProvidedProducts();
            verifyProductsOutput(sourceProducts, productsDTO);
            Set<Product> sourceDerivedProducts = source.getDerivedProvidedProducts();
            Set<PoolDTO.ProvidedProductDTO> derivedProductsDTO = dest.getDerivedProvidedProducts();
            verifyProductsOutput(sourceDerivedProducts, derivedProductsDTO);
        } else {
            assertNull(dest.getOwner());
            assertNull(dest.getSourceEntitlement());
            assertNull(dest.getBranding());
            assertNull(dest.getProvidedProducts());
            assertNull(dest.getDerivedProvidedProducts());
            assertNull(dest.getCertificate());
        }
    } else {
        assertNull(dest);
    }
}
Also used : ProvidedProduct(org.candlepin.model.ProvidedProduct) Product(org.candlepin.model.Product) Entitlement(org.candlepin.model.Entitlement) Branding(org.candlepin.model.Branding)

Example 7 with Branding

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

the class X509V3ExtensionUtilTest method productWithBrandName.

@Test
public void productWithBrandName() {
    String engProdId = "1000";
    String brandedName = "Branded Eng Product";
    Owner owner = new Owner("Test Corporation");
    Product p = new Product(engProdId, "Eng Product 1000");
    p.setAttribute(Product.Attributes.BRANDING_TYPE, "OS");
    Set<Product> prods = new HashSet<>(Arrays.asList(p));
    Product mktProd = new Product("mkt", "MKT SKU");
    Pool pool = TestUtil.createPool(mktProd);
    pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
    Consumer consumer = new Consumer();
    Entitlement e = new Entitlement(pool, consumer, owner, 10);
    List<org.candlepin.model.dto.Product> certProds = util.createProducts(mktProd, prods, "", new HashMap<>(), new Consumer(), pool);
    assertEquals(1, certProds.size());
    assertEquals(brandedName, certProds.get(0).getBrandName());
    assertEquals("OS", certProds.get(0).getBrandType());
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) Branding(org.candlepin.model.Branding) Consumer(org.candlepin.model.Consumer) Pool(org.candlepin.model.Pool) Entitlement(org.candlepin.model.Entitlement) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with Branding

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

the class X509V3ExtensionUtilTest method productWithMultipleBrandNames.

@Test
public void productWithMultipleBrandNames() {
    String engProdId = "1000";
    String brandedName = "Branded Eng Product";
    Owner owner = new Owner("Test Corporation");
    Product p = new Product(engProdId, "Eng Product 1000");
    p.setAttribute(Product.Attributes.BRANDING_TYPE, "OS");
    Set<Product> prods = new HashSet<>(Arrays.asList(p));
    Product mktProd = new Product("mkt", "MKT SKU");
    Pool pool = TestUtil.createPool(mktProd);
    pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
    pool.getBranding().add(new Branding(engProdId, "OS", "another brand name"));
    pool.getBranding().add(new Branding(engProdId, "OS", "number 3"));
    Set<String> possibleBrandNames = new HashSet<>();
    for (Branding b : pool.getBranding()) {
        possibleBrandNames.add(b.getName());
    }
    List<org.candlepin.model.dto.Product> certProds = util.createProducts(mktProd, prods, "", new HashMap<>(), new Consumer(), pool);
    assertEquals(1, certProds.size());
    // Should get the first name we encountered
    // but they're in a set so we can't test order
    String resultBrandName = certProds.get(0).getBrandName();
    String resultBrandType = certProds.get(0).getBrandType();
    assertTrue(possibleBrandNames.contains(resultBrandName));
    assertEquals("OS", resultBrandType);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) Branding(org.candlepin.model.Branding) Consumer(org.candlepin.model.Consumer) Pool(org.candlepin.model.Pool) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with Branding

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

the class PoolManagerFunctionalTest method testFabricateWithBranding.

@Test
public void testFabricateWithBranding() throws Exception {
    List<Pool> masterPools = poolManager.getPoolsBySubscriptionId(sub4.getId()).list();
    Pool masterPool = null;
    for (Pool pool : masterPools) {
        if (pool.getType() == Pool.PoolType.NORMAL) {
            masterPool = pool;
        }
    }
    Set<Branding> brandingSet = poolManager.fabricateSubscriptionFromPool(masterPool).getBranding();
    Assert.assertNotNull(brandingSet);
    Assert.assertEquals(2, brandingSet.size());
    ArrayList<Branding> list = new ArrayList<>();
    list.addAll(brandingSet);
    list.sort(new Comparator<Branding>() {

        @Override
        public int compare(Branding o1, Branding o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    Assert.assertEquals("branding1", list.get(0).getName());
    Assert.assertEquals("product1", list.get(0).getProductId());
    Assert.assertEquals("type1", list.get(0).getType());
    Assert.assertEquals("branding2", list.get(1).getName());
    Assert.assertEquals("product2", list.get(1).getProductId());
    Assert.assertEquals("type2", list.get(1).getType());
}
Also used : ArrayList(java.util.ArrayList) Pool(org.candlepin.model.Pool) Branding(org.candlepin.model.Branding) Test(org.junit.Test)

Example 10 with Branding

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

the class PoolRulesTest method brandingChanged.

@Test
public void brandingChanged() {
    Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
    Pool p1 = TestUtil.clone(p);
    // Add some branding to the pool and do an update:
    Branding b1 = new Branding("8000", "OS", "Awesome OS Branded");
    Branding b2 = new Branding("8001", "OS", "Awesome OS Branded 2");
    p.getBranding().add(b1);
    p.getBranding().add(b2);
    List<Pool> existingPools = Arrays.asList(p1);
    List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), Collections.<String, Product>emptyMap());
    assertEquals(1, updates.size());
    PoolUpdate update = updates.get(0);
    assertFalse(update.getProductsChanged());
    assertFalse(update.getDatesChanged());
    assertFalse(update.getQuantityChanged());
    assertTrue(update.getBrandingChanged());
    assertTrue(update.changed());
    assertEquals(2, update.getPool().getBranding().size());
    assertTrue(update.getPool().getBranding().contains(b1));
    assertTrue(update.getPool().getBranding().contains(b2));
}
Also used : Pool(org.candlepin.model.Pool) Branding(org.candlepin.model.Branding) PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Aggregations

Branding (org.candlepin.model.Branding)26 Pool (org.candlepin.model.Pool)15 Product (org.candlepin.model.Product)14 HashSet (java.util.HashSet)9 Entitlement (org.candlepin.model.Entitlement)9 SourceSubscription (org.candlepin.model.SourceSubscription)8 Test (org.junit.Test)7 Owner (org.candlepin.model.Owner)6 Date (java.util.Date)5 Consumer (org.candlepin.model.Consumer)5 ProvidedProduct (org.candlepin.model.ProvidedProduct)5 SubscriptionsCertificate (org.candlepin.model.SubscriptionsCertificate)5 CertificateSerial (org.candlepin.model.CertificateSerial)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 SourceStack (org.candlepin.model.SourceStack)3 ProductData (org.candlepin.model.dto.ProductData)3 Subscription (org.candlepin.model.dto.Subscription)3 LinkedList (java.util.LinkedList)2 EntitlementDTO (org.candlepin.dto.manifest.v1.EntitlementDTO)2