Package org.candlepin.model

Examples of org.candlepin.model.ProvidedProduct


        Consumer consumer = TestUtil.createConsumer(owner);
        ConsumerDto consumerDto = new ConsumerDto(consumer.getUuid(), consumer.getName(),
            consumer.getType(), consumer.getOwner(), "", "");

        Product parentProduct = TestUtil.createProduct();
        ProvidedProduct pp1 = TestUtil.createProvidedProduct();

        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().
View Full Code Here


    public void testFuzzyProductMatchingWithoutSubscription() {
        Product parent = TestUtil.createProduct();
        productCurator.create(parent);

        Set<ProvidedProduct> providedProducts = new HashSet<ProvidedProduct>();
        ProvidedProduct providedProduct = new ProvidedProduct(
            product.getId(), "Test Provided Product");
        providedProducts.add(providedProduct);

        Pool p = TestUtil.createPool(owner, parent, providedProducts, 5);
        providedProduct.setPool(p);
        poolCurator.create(p);
        List<Pool> results = poolCurator.listByOwnerAndProduct(owner, product.getId());
        assertEquals(1, results.size());
    }
View Full Code Here

    public void testPoolProducts() {
        Product another = TestUtil.createProduct();
        productCurator.create(another);

        Set<ProvidedProduct> providedProducts = new HashSet<ProvidedProduct>();
        ProvidedProduct providedProduct = new ProvidedProduct(
            another.getId(), "Test Provided Product");
        providedProducts.add(providedProduct);

        Pool pool = TestUtil.createPool(owner, product, providedProducts, 5);
        providedProduct.setPool(pool);
        poolCurator.create(pool);
        pool = poolCurator.find(pool.getId());
        assertTrue(pool.getProvidedProducts().size() > 0);
    }
View Full Code Here

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.getProvidedProducts().clear();
        p.getProvidedProducts().add(
            new ProvidedProduct(product3.getId(), product3.getName(), p));

        List<Pool> existingPools = new LinkedList<Pool>();
        existingPools.add(p);
        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);
        assertEquals(1, updates.size());
View Full Code Here

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.getProvidedProducts().clear();
        p.getProvidedProducts().add(
            new ProvidedProduct(product3.getId(), product3.getName(), p));

        List<Pool> existingPools = Arrays.asList(p);

        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);
        assertEquals(1, updates.size());
View Full Code Here

    private Entitlement mockEntitlement(Consumer consumer, String productId,
        Date start, Date end, String ... providedProductIds) {

        Set<ProvidedProduct> provided = new HashSet<ProvidedProduct>();
        for (String pid : providedProductIds) {
            provided.add(new ProvidedProduct(pid, pid));
        }
        Pool p = new Pool(owner, productId, productId, provided,
            new Long(1000), start, end, "1000", "1000", "1000");
        Entitlement e = new Entitlement(p, consumer, 1);
        e.setId("ent_" + TestUtil.randomInt());
View Full Code Here

            "2");
        Product product3 = mockProduct(productId3, "Test Provided product");

        Pool pool1 = mockPool(product1);
        pool1.setId("DEAD-BEEF");
        pool1.addProvidedProduct(new ProvidedProduct(product3.getId(), product3.getName()));

        Pool pool2 = mockPool(product2);
        pool2.setId("DEAD-BEEF2");
        pool2.addProvidedProduct(new ProvidedProduct(product3.getId(), product3.getName()));

        when(this.prodAdapter.getProductById(productId1)).thenReturn(product1);
        when(this.prodAdapter.getProductById(productId2)).thenReturn(product2);
        when(this.prodAdapter.getProductById(productId3)).thenReturn(product3);
View Full Code Here

        stackedEnts.add(createEntFromPool(pool3));
        PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool);
        assertTrue(update.getProductsChanged());
        assertEquals(3, stackDerivedPool.getProvidedProducts().size());
        assertTrue(stackDerivedPool.getProvidedProducts().contains(
            new ProvidedProduct(provided1.getId(), provided1.getName())));
        assertTrue(stackDerivedPool.getProvidedProducts().contains(
            new ProvidedProduct(provided2.getId(), provided2.getName())));
        assertTrue(stackDerivedPool.getProvidedProducts().contains(
            new ProvidedProduct(provided3.getId(), provided3.getName())));
    }
View Full Code Here

        }

        engProduct.setContent(productContent);
        Pool pool = TestUtil.createPool(owner, mktProduct);
        pool.setId("DEAD-BEEF");
        pool.addProvidedProduct(new ProvidedProduct(engProduct.getId(),
            engProduct.getName()));
        when(this.prodAdapter.getProductById(productId)).thenReturn(mktProduct);
        when(this.prodAdapter.getProductById(engProduct.getId())).thenReturn(engProduct);

        List<Pool> pools = new LinkedList<Pool>();
View Full Code Here

        }

        engProduct.setContent(productContent);
        Pool pool = TestUtil.createPool(owner, mktProduct);
        pool.setId("DEAD-BEEF");
        pool.addProvidedProduct(new ProvidedProduct(engProduct.getId(),
            engProduct.getName()));
        when(this.prodAdapter.getProductById(productId)).thenReturn(mktProduct);
        when(this.prodAdapter.getProductById(engProduct.getId())).thenReturn(engProduct);

        List<Pool> pools = new LinkedList<Pool>();
View Full Code Here

TOP

Related Classes of org.candlepin.model.ProvidedProduct

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.