Package org.candlepin.model

Examples of org.candlepin.model.Subscription


        when(product.getId()).thenReturn("product id");

        Pool pool = new Pool();
        pool.setSourceSubscription(new SourceSubscription("subId", "master"));
        pool.setOwner(owner);
        Subscription subscription = new Subscription();
        subscription.setId("subId");
        subscription.setOwner(owner);

        List<Pool> pools = Util.newList();
        pools.add(pool);
        List<Subscription> subscriptions = Util.newList();
        subscriptions.add(subscription);
View Full Code Here


        when(product.getId()).thenReturn("product id");
        when(product2.getId()).thenReturn("product id 2");

        Pool pool = new Pool();
        pool.setSourceSubscription(new SourceSubscription("subId", "master"));
        Subscription subscription = new Subscription();
        subscription.setId("subId");

        List<Pool> pools = Util.newList();
        pools.add(pool);
        List<Subscription> subscriptions = Util.newList();
        subscriptions.add(subscription);
View Full Code Here

        productCurator.create(derivedProvidedProduct);

        Set<Product> derivedProvidedProducts = new HashSet<Product>();
        derivedProvidedProducts.add(derivedProvidedProduct);

        sub = new Subscription(owner, product, providedProducts, 16L,
            TestUtil.createDate(2006, 10, 21), TestUtil.createDate(2020, 1, 1), new Date());
        sub.setDerivedProduct(derivedProduct);
        sub.setDerivedProvidedProducts(derivedProvidedProducts);
        subCurator.create(sub);
    }
View Full Code Here

        productAdapter.createProduct(virtHostPlatform);
        productAdapter.createProduct(virtGuest);
        productAdapter.createProduct(monitoring);
        productAdapter.createProduct(provisioning);

        subCurator.create(new Subscription(o, virtHost, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date()));
        subCurator.create(new Subscription(o, virtHostPlatform, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date()));

        subCurator.create(new Subscription(o, monitoring, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date()));
        subCurator.create(new Subscription(o, provisioning, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date()));

        poolManager.getRefresher().add(o).run();

        this.systemType = new ConsumerType(ConsumerTypeEnum.SYSTEM);
View Full Code Here

        modifier.addContent(content);

        contentCurator.create(content);
        productAdapter.createProduct(modifier);

        subCurator.create(new Subscription(o, modifier, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date()));

        poolManager.getRefresher().add(o).run();

View Full Code Here

        Product product2 = TestUtil.createProduct("product 2", "Product 2");

        productAdapter.createProduct(product1);
        productAdapter.createProduct(product2);

        Subscription subscription = new Subscription(o, product1, new HashSet<Product>(),
            5L, new Date(), TestUtil.createDate(3020, 12, 12), new Date());
        subCurator.create(subscription);

        // set up initial pool
        poolManager.getRefresher().add(o).run();

        List<Pool> pools = poolCurator.listByOwnerAndProduct(o, product1.getId());
        assertEquals(1, pools.size());

        // now alter the product behind the sub, and make sure the pool is also updated
        subscription.setProduct(product2);
        subCurator.merge(subscription);

        // set up initial pool
        poolManager.getRefresher().add(o).run();
View Full Code Here

    public void copyProductAttributesOntoPoolAddsNewAttribute() {
        Product targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        targetProduct.setAttribute("A1", "V1");
        targetProduct.setAttribute("A2", "V2");
        Subscription sourceSub = TestUtil.createSubscription(targetProduct);

        Pool targetPool = TestUtil.createPool(targetProduct);
        // createPool will simulate the copy automatically - reset them.
        targetPool.setProductAttributes(new HashSet<ProductPoolAttribute>());

        PoolHelper ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertTrue("Update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertEquals(2, targetPool.getProductAttributes().size());
        assertTrue(targetPool.hasProductAttribute("A1"));
        assertTrue(targetPool.hasProductAttribute("A2"));
    }
View Full Code Here

    @Test
    public void copyProductAttributesOntoPoolUpdatesExistingAttribute() {
        Product targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        targetProduct.setAttribute("A1", "V-updated");
        Subscription sourceSub = TestUtil.createSubscription(targetProduct);

        Pool targetPool = TestUtil.createPool(targetProduct);
        targetPool.setProductAttribute("A1", "V1", targetProduct.getId());

        PoolHelper ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertTrue("Update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertEquals(1, targetPool.getProductAttributes().size());
        assertTrue(targetPool.hasProductAttribute("A1"));
        assertEquals("V-updated", targetPool.getProductAttribute("A1").getValue());
    }
View Full Code Here

    protected Pool createPoolAndSub(Owner owner, Product product,
        Long quantity, Date startDate, Date endDate) {
        Pool p = new Pool(owner, product.getId(), product.getName(),
            new HashSet<ProvidedProduct>(), quantity, startDate, endDate,
            DEFAULT_CONTRACT, DEFAULT_ACCOUNT, DEFAULT_ORDER);
        Subscription sub = new Subscription(owner, product,
            new HashSet<Product>(), quantity, startDate, endDate,
            TestUtil.createDate(2010, 2, 12));
        subCurator.create(sub);
        p.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
        for (ProductAttribute pa : product.getAttributes()) {
            p.addProductAttribute(new ProductPoolAttribute(pa.getName(),
                pa.getValue(), product.getId()));
        }
        return poolCurator.create(p);
View Full Code Here

    @Test
    public void copyProductAttributesOntoPoolWithNulls() {
        Product targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        targetProduct.setAttribute("A1", "V-updated");
        Subscription sourceSub = TestUtil.createSubscription(targetProduct);

        Pool targetPool = TestUtil.createPool(targetProduct);
        targetPool.setProductAttribute("A1", null, targetProduct.getId());

        PoolHelper ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertTrue("Update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertEquals(1, targetPool.getProductAttributes().size());
        assertTrue(targetPool.hasProductAttribute("A1"));
        assertEquals("V-updated", targetPool.getProductAttribute("A1").getValue());

        targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        targetProduct.setAttribute("A1", null);
        sourceSub = TestUtil.createSubscription(targetProduct);

        targetPool = TestUtil.createPool(targetProduct);
        targetPool.setProductAttribute("A1", "V-updated-new", targetProduct.getId());

        ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertTrue("Update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertEquals(1, targetPool.getProductAttributes().size());
        assertTrue(targetPool.hasProductAttribute("A1"));
        assertEquals(null, targetPool.getProductAttribute("A1").getValue());

        targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        targetProduct.setAttribute("A1", null);
        sourceSub = TestUtil.createSubscription(targetProduct);

        targetPool = TestUtil.createPool(targetProduct);
        targetPool.setProductAttribute("A1", null, targetProduct.getId());

        ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertFalse("No update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertEquals(1, targetPool.getProductAttributes().size());
        assertTrue(targetPool.hasProductAttribute("A1"));
        assertEquals(null, targetPool.getProductAttribute("A1").getValue());
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.Subscription

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.