Package org.candlepin.model

Examples of org.candlepin.model.Pool


        p.addProductAttribute(new ProductPoolAttribute("stacking_id", stackId, productId));
        return e;
    }

    private Entitlement mockEntitlement(Consumer consumer, String productId, String name) {
        Pool p = new Pool(owner, productId, name, null,
            new Long(1000), TestUtil.createDate(2000, 1, 1),
            TestUtil.createDate(2050, 1, 1), "1000", "1000", "1000");
        Entitlement e = new Entitlement(p, consumer, 1);
        return e;
    }
View Full Code Here


        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool ghost = TestUtil.createPool(owner, prod1, 5);
        ghost.setId("ghost-pool");
        key1.addPool(ghost, 10L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(ghost.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

    @Test
    public void hostedInstanceBasedUpdatePool() {
        Subscription s = createInstanceBasedSub("INSTANCEPROD", 100, 2, false);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        Pool pool = pools.get(0);

        // Change the value of instance multiplier:
        s.getProduct().setAttribute("instance_multiplier", "4");
        // Change the quantity:
        s.setQuantity(new Long(200));
View Full Code Here

    @Test
    public void hostedInstanceBasedRemoved() {
        Subscription s = createInstanceBasedSub("INSTANCEPROD", 100, 2, false);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        Pool pool = pools.get(0);

        // Remove the instance multiplier attribute entirely, pool quantity should
        // revert to half of what it was. No existing entitlements need to be adjusted,
        // we will let a (future) overconsumption routine handle that.
        ProductAttribute pa = s.getProduct().getAttribute("instance_multiplier");
View Full Code Here

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key1.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
View Full Code Here

    @Test
    public void standaloneInstanceBasedUpdatePool() {
        Subscription s = createInstanceBasedSub("INSTANCEPROD", 100, 2, true);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        Pool pool = pools.get(0);

        // Change the value of instance multiplier:
        s.getProduct().setAttribute("instance_multiplier", "4");
        // Change the quantity as well:
        s.setQuantity(new Long(200));
View Full Code Here

        ActivationKey key2 = new ActivationKey("key2", owner);
        keys.add(key1);
        keys.add(key2);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key2.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
View Full Code Here

*/
public class HostedVirtLimitEntitlementRulesTest extends EntitlementRulesTestFixture {

    @Test
    public void hostedParentConsumerPostCreatesNoPool() {
        Pool pool = setupVirtLimitPool();
        Entitlement e = new Entitlement(pool, consumer, 1);

        PoolHelper postHelper = mock(PoolHelper.class);
        when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        enforcer.postEntitlement(consumer, postHelper, e);

        verify(postHelper, never()).createHostRestrictedPool(pool.getProductId(),
            pool, pool.getAttributeValue("virt_limit"));
    }
View Full Code Here

        Subscription s = createVirtLimitSub("virtLimitProduct", 10, "10");
        consumer.setType(new ConsumerType(ConsumerTypeEnum.CANDLEPIN));
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool physicalPool = pools.get(0);
        physicalPool.setId("physical");
        Pool virtBonusPool = pools.get(1);
        virtBonusPool.setId("virt");

        assertEquals(new Long(10), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());

        // Quantity on bonus pool should be virt limit * sub quantity:
        assertEquals(new Long(100), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("10", virtBonusPool.getProductAttribute("virt_limit").getValue());

        Entitlement e = new Entitlement(physicalPool, consumer, 1);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);
        List<Pool> poolList = new ArrayList<Pool>();
        poolList.add(virtBonusPool);
View Full Code Here

        Subscription s = createVirtLimitSub("virtLimitProduct", 10, "unlimited");
        s.getProduct().setAttribute("host_limited", "true");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());

        Pool physicalPool = pools.get(0);
        physicalPool.setId("physical");

        assertEquals(new Long(10), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());

        Entitlement e = new Entitlement(physicalPool, consumer, 1);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);

        enforcer.postEntitlement(consumer, postHelper, e);
View Full Code Here

TOP

Related Classes of org.candlepin.model.Pool

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.