Package org.candlepin.model

Examples of org.candlepin.model.Subscription


        assertTrue(updatedPool.hasSubProductAttribute("a"));
    }

    @Test
    public void updateDerivedPoolWithNewSubProductAttributes() {
        Subscription s = createSubscriptionWithSubProduct();
        Pool p = TestUtil.copyFromSub(s);

        // Simulate that this is a derived pool. When we add a new sub-product attribute
        // to the subscription, it should show up as a primary product attribute on a
        // sub pool:
        p.setAttribute("pool_derived", "true");

        // Update the subscription's sub-product:
        s.getDerivedProduct().setAttribute("a", "new value");

        List<Pool> existingPools = Arrays.asList(p);
        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);

        assertEquals(1, updates.size());
View Full Code Here


        assertFalse(updatedPool.hasSubProductAttribute("a"));
    }

    @Test
    public void updatePoolWithModifiedProductAttributes() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        Pool p = TestUtil.copyFromSub(s);

        String testAttributeKey = "multi-entitlement";
        String expectedAttributeValue = "yes";

        // Simulate an attribute that was added during pool creation:
        p.setProductAttribute(testAttributeKey, "no", s.getProduct().getId());

        // Update the subscription's product with new attribute value:
        s.getProduct().setAttribute(testAttributeKey, expectedAttributeValue);

        when(productAdapterMock.getProductById(s.getProduct().getId()))
            .thenReturn(s.getProduct());

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

            updatedPool.getProductAttribute(testAttributeKey).getValue());
    }

    @Test
    public void updatePoolWithModifiedSubProductAttributes() {
        Subscription s = createSubscriptionWithSubProduct();
        s.getDerivedProduct().setAttribute("a", "orig value");
        Pool p = TestUtil.copyFromSub(s);

        // Update the subscription's sub-product:
        String newVal = "new value";
        s.getDerivedProduct().setAttribute("a", newVal);

        List<Pool> existingPools = Arrays.asList(p);
        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);

        assertEquals(1, updates.size());
View Full Code Here

        assertTrue(updatedPool.hasSubProductAttribute("a"));
        assertEquals(newVal, updatedPool.getDerivedProductAttribute("a").getValue());
    }

    private Subscription createSubscriptionWithSubProduct() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        Product subProd = TestUtil.createProduct();
        s.setDerivedProduct(subProd);
        when(productAdapterMock.getProductById(s.getProduct().getId()))
            .thenReturn(s.getProduct());
        when(productAdapterMock.getProductById(s.getDerivedProduct().getId()))
            .thenReturn(s.getDerivedProduct());
        return s;
    }
View Full Code Here

        return s;
    }

    @Test
    public void updateDerivedPoolWithModifiedSubProductAttributes() {
        Subscription s = createSubscriptionWithSubProduct();
        Pool p = TestUtil.copyFromSub(s);
        p.setAttribute("pool_derived", "true");

        s.getDerivedProduct().setAttribute("a", "orig value");
        // Simulate that this is a derived pool. When we add a new sub-product attribute
        // to the subscription, it should show up as a primary product attribute on a
        // sub pool:

        // Update the subscription's sub-product:
        String newVal = "new value";
        s.getDerivedProduct().setAttribute("a", newVal);

        List<Pool> existingPools = Arrays.asList(p);
        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);

        assertEquals(1, updates.size());
View Full Code Here

    }

    @Test
    public void updatePoolSubProvidedProductsChanged() {
        // Subscription with two provided products:
        Subscription s = createSubscriptionWithSubProduct();
        Product product1 = TestUtil.createProduct();
        Product product2 = TestUtil.createProduct();
        Product product3 = TestUtil.createProduct();
        s.getDerivedProvidedProducts().add(product1);
        s.getDerivedProvidedProducts().add(product2);

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.getProvidedProducts().clear();
        p.getProvidedProducts().add(
View Full Code Here

        assertEquals(2, updates.get(0).getPool().getDerivedProvidedProducts().size());
    }

    @Test
    public void productIdChangeOnProductPoolAttributeTriggersUpdate() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        String testAttributeKey = "multi-entitlement";
        s.getProduct().setAttribute(testAttributeKey, "yes");

        Pool p = TestUtil.copyFromSub(s);
        p.setProductAttribute(testAttributeKey, "yes", s.getProduct().getId());

        // Change the sub's product's ID
        String expectedProductId = "NEW_TEST_ID";
        s.getProduct().setId(expectedProductId);

        when(productAdapterMock.getProductById(s.getProduct().getId()))
            .thenReturn(s.getProduct());

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

    @Test
    public void productAttributesCopiedOntoPoolWhenCreatingNewPool() {
        Product product = TestUtil.createProduct();

        Subscription sub = TestUtil.createSubscription(owner, product);
        String testAttributeKey = "multi-entitlement";
        String expectedAttributeValue = "yes";
        sub.getProduct().setAttribute(testAttributeKey, expectedAttributeValue);

        when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);

        List<Pool> pools = this.poolRules.createPools(sub);
        assertEquals(1, pools.size());
View Full Code Here

    @Test
    public void brandingCopiedWhenCreatingPools() {
        Product product = TestUtil.createProduct();

        Subscription sub = TestUtil.createSubscription(owner, product);
        Branding b1 = new Branding("8000", "OS", "Branded Awesome OS");
        Branding b2 = new Branding("8001", "OS", "Branded Awesome OS 2");
        sub.getBranding().add(b1);
        sub.getBranding().add(b2);

        when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);

        List<Pool> pools = this.poolRules.createPools(sub);
        assertEquals(1, pools.size());
View Full Code Here

    @Test
    public void subProductAttributesCopiedOntoPoolWhenCreatingNewPool() {
        Product product = TestUtil.createProduct();
        Product subProduct = TestUtil.createProduct();

        Subscription sub = TestUtil.createSubscription(owner, product);
        sub.setDerivedProduct(subProduct);
        String testAttributeKey = "multi-entitlement";
        String expectedAttributeValue = "yes";
        subProduct.setAttribute(testAttributeKey, expectedAttributeValue);

        when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);
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.