Package org.candlepin.model

Examples of org.candlepin.model.Subscription


    }

    @Test
    public void hostedVirtLimitBadValueDoesntTraceBack() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        s.getProduct().addAttribute(new ProductAttribute("virt_limit", "badvalue"));
        s.setQuantity(10L);


        List<Pool> pools = null;
        try {
            pools = poolRules.createPools(s);
View Full Code Here


    }

    @Test
    public void providedProductsChanged() {
        // Subscription with two provided products:
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        Product product1 = TestUtil.createProduct();
        Product product2 = TestUtil.createProduct();
        Product product3 = TestUtil.createProduct();
        s.getProvidedProducts().add(product1);
        s.getProvidedProducts().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

        assertFalse(update.getQuantityChanged());
    }

    @Test
    public void productNameChanged() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.setProductName("somethingelse");

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

        assertEquals(1, updates.size());
        PoolUpdate update = updates.get(0);
        assertTrue(update.getProductsChanged());
        assertFalse(update.getDatesChanged());
        assertFalse(update.getQuantityChanged());
        assertEquals(s.getProduct().getName(), update.getPool().getProductName());
    }
View Full Code Here

        assertEquals(s.getProduct().getName(), update.getPool().getProductName());
    }

    @Test
    public void datesNameChanged() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.setEndDate(new Date());

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

        assertEquals(1, updates.size());
        PoolUpdate update = updates.get(0);
        assertFalse(update.getProductsChanged());
        assertTrue(update.getDatesChanged());
        assertFalse(update.getQuantityChanged());
        assertEquals(s.getEndDate(), update.getPool().getEndDate());
    }
View Full Code Here

        assertEquals(s.getEndDate(), update.getPool().getEndDate());
    }

    @Test
    public void quantityChanged() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.setQuantity(2000L);

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

        assertEquals(1, updates.size());
        PoolUpdate update = updates.get(0);
        assertFalse(update.getProductsChanged());
        assertFalse(update.getDatesChanged());
        assertTrue(update.getQuantityChanged());
        assertEquals(s.getQuantity(), update.getPool().getQuantity());
    }
View Full Code Here

        assertEquals(s.getQuantity(), update.getPool().getQuantity());
    }

    @Test
    public void brandingChanged() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());

        Pool p = TestUtil.copyFromSub(s);

        // Add some branding to the subscription and do an update:
        Branding b1 = new Branding("8000", "OS", "Awesome OS Branded");
        Branding b2 = new Branding("8001", "OS", "Awesome OS Branded 2");
        s.getBranding().add(b1);
        s.getBranding().add(b2);

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

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

        assertTrue(update.getPool().getBranding().contains(b2));
    }

    @Test
    public void brandingDidntChange() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());

        // Add some branding to the subscription and do an update:
        Branding b1 = new Branding("8000", "OS", "Awesome OS Branded");
        Branding b2 = new Branding("8001", "OS", "Awesome OS Branded 2");
        s.getBranding().add(b1);
        s.getBranding().add(b2);

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

        // Copy the pool with the branding to begin with:
        Pool p = TestUtil.copyFromSub(s);

        List<Pool> existingPools = Arrays.asList(p);
View Full Code Here

        assertEquals(0, updates.size());
    }

    @Test
    public void virtOnlyQuantityChanged() {
        Subscription s = TestUtil.createSubscription(owner, TestUtil.createProduct());
        s.getProduct().addAttribute(new ProductAttribute("virt_limit", "5"));
        s.setQuantity(10L);

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

        // Setup a pool with a single (different) provided product:
        Pool p = TestUtil.copyFromSub(s);
        p.addAttribute(new PoolAttribute("virt_only", "true"));
        p.addAttribute(new PoolAttribute("pool_derived", "true"));
View Full Code Here

        assertEquals(Long.valueOf(50), update.getPool().getQuantity());
    }

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

        // Update the subscription's product.
        String testAttributeKey = "multi-entitlement";
        s.getProduct().setAttribute(testAttributeKey, "yes");

        when(productAdapterMock.getProductById(s.getProduct().getId()))
            .thenReturn(s.getProduct());
        List<Pool> existingPools = Arrays.asList(p);
        List<PoolUpdate> updates = this.poolRules.updatePools(s, existingPools);

        assertEquals(1, updates.size());
        PoolUpdate update = updates.get(0);
View Full Code Here

        assertTrue(updatedPool.hasProductAttribute(testAttributeKey));
    }

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

        // 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

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.