Package org.candlepin.model

Examples of org.candlepin.model.Subscription


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

        Subscription sub = TestUtil.createSubscription(owner, product);
        sub.setDerivedProduct(subProduct);

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

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


    public void subProvidedProductsCopiedOntoPoolWhenCreatingNewPool() {
        Product product = TestUtil.createProduct();
        Product subProduct = TestUtil.createProduct();
        Product subProvidedProduct = TestUtil.createProduct();

        Subscription sub = TestUtil.createSubscription(owner, product);
        sub.setDerivedProduct(subProduct);
        Set<Product> subProvided = new HashSet<Product>();
        subProvided.add(subProvidedProduct);
        sub.setDerivedProvidedProducts(subProvided);

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

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

    private Subscription createVirtLimitSub(String productId, int quantity, int virtLimit) {
        Product product = new Product(productId, productId);
        product.setAttribute("virt_limit", Integer.toString(virtLimit));
        when(productAdapterMock.getProductById(productId)).thenReturn(product);
        Subscription s = TestUtil.createSubscription(product);
        s.setQuantity(new Long(quantity));
        return s;
    }
View Full Code Here

     * pools will be created during binding.
     */
    @Test
    public void hostedVirtLimitWithHostLimitedSkipsBonusPools() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("host_limited", "true");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
    }
View Full Code Here

    // Make sure host_limited false is working:
    @Test
    public void hostedVirtLimitWithHostLimitedFalseCreatesBonusPools() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("host_limited", "false");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());
    }
View Full Code Here

    }

    @Test
    public void hostedVirtLimitSubCreatesBonusVirtOnlyPool() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool physicalPool = pools.get(0);
        Pool virtBonusPool = pools.get(1);
View Full Code Here

    }

    @Test
    public void hostedVirtLimitSubCreatesUnlimitedBonusVirtOnlyPool() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("virt_limit", "unlimited");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool virtBonusPool = pools.get(1);
View Full Code Here

    }

    @Test
    public void hostedVirtLimitSubUpdatesUnlimitedBonusVirtOnlyPool() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("virt_limit", "unlimited");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool virtBonusPool = pools.get(1);

        // Quantity on bonus pool should be unlimited:
        assertEquals(new Long(-1), virtBonusPool.getQuantity());

        // Now we update the sub and see if that unlimited pool gets adjusted:
        s.getProduct().setAttribute("virt_limit", "10");
        List<PoolUpdate> updates = poolRules.updatePools(s, pools);
        assertEquals(2, updates.size());

        PoolUpdate virtUpdate = updates.get(1);
        assertEquals(new Long(100), virtUpdate.getPool().getQuantity());
View Full Code Here

    }

    @Test
    public void hostedVirtLimitRemoved() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("virt_limit", "4");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        // Now we update the sub and see if that unlimited pool gets adjusted:
        s.getProduct().getAttributes().clear();
        List<PoolUpdate> updates = poolRules.updatePools(s, pools);
        assertEquals(2, updates.size());

        // Regular pool should be in a sane state:
        PoolUpdate baseUpdate = updates.get(0);
View Full Code Here

    }

    @Test
    public void hostedVirtLimitSubWithMultiplierCreatesUnlimitedBonusVirtOnlyPool() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("virt_limit", "unlimited");
        s.getProduct().setMultiplier(5L);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool virtBonusPool = pools.get(1);
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.