Package org.candlepin.model

Examples of org.candlepin.model.DerivedProvidedProduct


            "Test Provided Product " + random);
    }

    public static DerivedProvidedProduct createSubProvidedProduct() {
        int random = randomInt();
        return new DerivedProvidedProduct("test-sub-provided-product-" + random,
            "Test Sub Provided Product " + random);
    }
View Full Code Here


    public void exportProducts() throws Exception {
        config.setProperty(ConfigProperties.SYNC_WORK_DIR, "/tmp/");
        Consumer consumer = mock(Consumer.class);
        Entitlement ent = mock(Entitlement.class);
        ProvidedProduct pp = mock(ProvidedProduct.class);
        DerivedProvidedProduct spp = mock(DerivedProvidedProduct.class);
        Pool pool = mock(Pool.class);
        Rules mrules = mock(Rules.class);
        Principal principal = mock(Principal.class);
        IdentityCertificate idcert = new IdentityCertificate();

        Set<ProvidedProduct> ppset = new HashSet<ProvidedProduct>();
        ppset.add(pp);

        Set<DerivedProvidedProduct> sppSet = new HashSet<DerivedProvidedProduct>();
        sppSet.add(spp);

        Set<Entitlement> entitlements = new HashSet<Entitlement>();
        entitlements.add(ent);

        Product prod = new Product("12345", "RHEL Product");
        prod.setMultiplier(1L);
        prod.setCreated(new Date());
        prod.setUpdated(new Date());
        prod.setHref("http://localhost");
        prod.setAttributes(Collections.EMPTY_SET);

        Product prod1 = new Product("MKT-prod", "RHEL Product");
        prod1.setMultiplier(1L);
        prod1.setCreated(new Date());
        prod1.setUpdated(new Date());
        prod1.setHref("http://localhost");
        prod1.setAttributes(Collections.EMPTY_SET);

        Product subProduct = new Product("MKT-sub-prod", "Sub Product");
        subProduct.setMultiplier(1L);
        subProduct.setCreated(new Date());
        subProduct.setUpdated(new Date());
        subProduct.setHref("http://localhost");
        subProduct.setAttributes(Collections.EMPTY_SET);

        Product subProvidedProduct = new Product("332211", "Sub Product");
        subProvidedProduct.setMultiplier(1L);
        subProvidedProduct.setCreated(new Date());
        subProvidedProduct.setUpdated(new Date());
        subProvidedProduct.setHref("http://localhost");
        subProvidedProduct.setAttributes(Collections.EMPTY_SET);

        ProductCertificate pcert = new ProductCertificate();
        pcert.setKey("euh0876puhapodifbvj094");
        pcert.setCert("hpj-08ha-w4gpoknpon*)&^%#");
        pcert.setCreated(new Date());
        pcert.setUpdated(new Date());

        when(pp.getProductId()).thenReturn("12345");
        when(pool.getProvidedProducts()).thenReturn(ppset);
        when(pool.getProductId()).thenReturn("MKT-prod");

        when(pool.getDerivedProvidedProducts()).thenReturn(sppSet);
        when(pool.getDerivedProductId()).thenReturn(subProduct.getId());
        when(spp.getProductId()).thenReturn(subProvidedProduct.getId());

        when(ent.getPool()).thenReturn(pool);
        when(mrules.getRules()).thenReturn("foobar");
        when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
            "signature".getBytes());
View Full Code Here

        product.setAttribute("multi-entitlement", "yes");
        product.setAttribute("sockets", "2");

        Set<DerivedProvidedProduct> derivedProvided =
            new HashSet<DerivedProvidedProduct>();
        derivedProvided.add(new DerivedProvidedProduct(derivedEngPid, derivedEngPid));

        Product derivedProduct = new Product("derivedProd", "A derived test product");
        product.setAttribute("stacking_id", "1");
        product.setAttribute("multi-entitlement", "yes");
View Full Code Here

        Product mainPoolProduct = TestUtil.createProduct();
        mainPoolProduct.getAttributes().clear();
        mainPoolProduct.setAttribute("A1", "V1");
        mainPoolProduct.setAttribute("A2", "V2");

        DerivedProvidedProduct subProvided1 =
            new DerivedProvidedProduct("sub-pp-1", "Sub Provided 1");
        DerivedProvidedProduct subProvided2 =
            new DerivedProvidedProduct("sub-pp-2", "Sub Provided 2");

        Set<DerivedProvidedProduct> subProvidedProducts =
            new HashSet<DerivedProvidedProduct>();
        subProvidedProducts.add(subProvided1);
        subProvidedProducts.add(subProvided2);

        Product subProduct = TestUtil.createProduct();
        subProduct.getAttributes().clear();
        subProduct.setAttribute("SA1", "SV1");
        subProduct.setAttribute("SA2", "SV2");

        Pool targetPool = TestUtil.createPool(mainPoolProduct);
        targetPool.setId("sub-prod-pool");
        targetPool.setDerivedProductId(subProduct.getId());
        targetPool.setDerivedProductName(subProduct.getName());
        targetPool.setDerivedProvidedProducts(subProvidedProducts);

        when(psa.getProductById(subProduct.getId())).thenReturn(subProduct);
        when(ent.getConsumer()).thenReturn(cons);

        PoolHelper ph = new PoolHelper(pm, productCache, ent);
        Pool hostRestrictedPool = ph.createHostRestrictedPool(
            targetPool.getDerivedProductId(), targetPool, "unlimited");

        assertEquals(targetPool.getId(),
            hostRestrictedPool.getAttributeValue("source_pool_id"));
        assertEquals(-1L, (long) hostRestrictedPool.getQuantity());
        assertEquals(2, hostRestrictedPool.getProductAttributes().size());
        assertTrue(hostRestrictedPool.hasProductAttribute("SA1"));
        assertEquals("SV1", hostRestrictedPool.getProductAttribute("SA1").getValue());
        assertTrue(hostRestrictedPool.hasProductAttribute("SA2"));
        assertEquals("SV2", hostRestrictedPool.getProductAttribute("SA2").getValue());

        // Check that the sub provided products made it to the sub pool
        Set<String> providedProdIds = new HashSet<String>();
        for (ProvidedProduct pp : hostRestrictedPool.getProvidedProducts()) {
            providedProdIds.add(pp.getProductId());
            // Make sure that the correct pool was associated
            assertEquals(hostRestrictedPool, pp.getPool());
        }
        assertEquals(2, providedProdIds.size());
        assertTrue(providedProdIds.contains(subProvided1.getProductId()));
        assertTrue(providedProdIds.contains(subProvided2.getProductId()));
    }
View Full Code Here

        productCurator.create(derivedProd);

        Pool p = TestUtil.createPool(owner, prod1, new HashSet<ProvidedProduct>(), 1000);
        p.addProvidedProduct(new ProvidedProduct(prod2.getId(), prod2.getName()));
        Set<DerivedProvidedProduct> derivedProducts = new HashSet<DerivedProvidedProduct>();
        derivedProducts.add(new DerivedProvidedProduct(derivedProd.getId(),
            derivedProd.getName(), p));

        p.setDerivedProvidedProducts(derivedProducts);
        poolCurator.create(p);
View Full Code Here

        Set<ProvidedProduct> provided = new HashSet<ProvidedProduct>();
        provided.add(pp1);

        // Sub product setup
        Product subProduct = TestUtil.createProduct();
        DerivedProvidedProduct subProvided1 = TestUtil.createSubProvidedProduct();

        Set<DerivedProvidedProduct> subProvidedProducts =
            new HashSet<DerivedProvidedProduct>();
        subProvidedProducts.add(subProvided1);

        Pool pool = TestUtil.createPool(owner, parentProduct, provided, subProduct.getId(),
            subProvidedProducts, 3);
        EntitlementCertificate cert = createEntitlementCertificate("my-test-key",
            "my-cert");
        Entitlement ent = TestUtil.createEntitlement(owner, consumer, pool, cert);
        ent.setQuantity(3);

        Reader reader = mock(Reader.class);
        when(om.readValue(reader, Entitlement.class)).thenReturn(ent);

        // Create our expected products
        Map<String, Product> productsById = new HashMap<String, Product>();
        productsById.put(parentProduct.getId(), parentProduct);
        productsById.put(pp1.getProductId(),
            TestUtil.createProduct(pp1.getProductId(), pp1.getProductName()));
        productsById.put(subProduct.getId(), subProduct);
        productsById.put(subProvided1.getProductId(), TestUtil.createProduct(
            subProvided1.getProductId(), subProvided1.getProductName()));

        Meta meta = new Meta();
        meta.setCdnLabel("test-cdn");
        Cdn testCdn = new Cdn("test-cdn",
            "Test CDN", "https://test.url.com");
        when(cdnCurator.lookupByLabel("test-cdn")).thenReturn(testCdn);

        Subscription sub = importer.importObject(om, reader, owner,
            productsById, consumerDto, meta);

        assertEquals(pool.getId(), sub.getUpstreamPoolId());
        assertEquals(consumer.getUuid(), sub.getUpstreamConsumerId());
        assertEquals(ent.getId(), sub.getUpstreamEntitlementId());

        assertEquals(owner, sub.getOwner());
        assertEquals(ent.getStartDate(), sub.getStartDate());
        assertEquals(ent.getEndDate(), sub.getEndDate());

        assertEquals(pool.getAccountNumber(), sub.getAccountNumber());
        assertEquals(pool.getContractNumber(), sub.getContractNumber());
        assertEquals(pool.getOrderNumber(), sub.getOrderNumber());

        assertEquals(ent.getQuantity().intValue(), sub.getQuantity().intValue());

        assertEquals(parentProduct, sub.getProduct());
        assertEquals(provided.size(), sub.getProvidedProducts().size());
        assertEquals(pp1.getProductId(), sub.getProvidedProducts().
            iterator().next().getId());

        assertEquals(subProduct, sub.getDerivedProduct());
        assertEquals(1, sub.getDerivedProvidedProducts().size());
        assertEquals(subProvided1.getProductId(), sub.getDerivedProvidedProducts().
            iterator().next().getId());

        assertNotNull(sub.getCertificate());
        CertificateSerial serial = sub.getCertificate().getSerial();
        assertEquals(cert.getSerial().isCollected(), serial.isCollected());
View Full Code Here

                }
            }

            if (sub.getDerivedProvidedProducts() != null) {
                for (Product p : sub.getDerivedProvidedProducts()) {
                    DerivedProvidedProduct providedProduct =
                        new DerivedProvidedProduct(p.getId(), p.getName());
                    providedProduct.setPool(newPool);
                    subProvidedProducts.add(providedProduct);
                }
            }

            helper.copyProductAttributesOntoPool(sub.getProduct().getId(), newPool);
View Full Code Here

            existingPool.getDerivedProvidedProducts();
        Set<DerivedProvidedProduct> incomingProvided =
            new HashSet<DerivedProvidedProduct>();
        if (sub.getDerivedProvidedProducts() != null) {
            for (Product p : sub.getDerivedProvidedProducts()) {
                incomingProvided.add(new DerivedProvidedProduct(p.getId(), p.getName(),
                    existingPool));
            }
        }
        productsChanged = productsChanged || !currentProvided.equals(incomingProvided);
View Full Code Here

TOP

Related Classes of org.candlepin.model.DerivedProvidedProduct

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.