Package org.candlepin.model

Examples of org.candlepin.model.Entitlement


    @Test(expected = BadRequestException.class)
    public void migrateEntitlementQuantityFail() {
        ConsumerType ct = TestUtil.createConsumerType();
        ct.setManifest(true);
        Entitlement e = TestUtil.createEntitlement();
        Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct);
        Consumer destConsumer = new Consumer("destination-consumer", "bill", owner, ct);
        e.setConsumer(sourceConsumer);
        e.setQuantity(25);

        when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
        when(consumerCurator.verifyAndLookupConsumer(eq(destConsumer.getUuid())))
            .thenReturn(destConsumer);

        entResource.migrateEntitlement(e.getId(), destConsumer.getUuid(), 30);
    }
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);
View Full Code Here

        // 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);
        when(poolManagerMock.lookupBySubscriptionId(eq(physicalPool.getSubscriptionId())))
            .thenReturn(poolList);
View Full Code Here

    @Test(expected = BadRequestException.class)
    public void migrateEntitlementSourceConsumerFail() {
        ConsumerType ct = TestUtil.createConsumerType();
        ct.setManifest(true);
        Entitlement e = TestUtil.createEntitlement();
        Consumer destConsumer = new Consumer("destination-consumer", "bill", owner, ct);
        e.setConsumer(consumer);
        e.setQuantity(25);

        when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
        when(consumerCurator.verifyAndLookupConsumer(eq(destConsumer.getUuid()))).thenReturn(destConsumer);

        entResource.migrateEntitlement(e.getId(), destConsumer.getUuid(), 15);
    }
View Full Code Here

        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);
        verify(poolManagerMock).createPool(any(Pool.class));
    }
View Full Code Here

        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", 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);
        when(poolManagerMock.lookupBySubscriptionId(eq(physicalPool.getSubscriptionId())))
            .thenReturn(poolList);
View Full Code Here

        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", virtBonusPool.getProductAttribute("virt_limit")
            .getValue());

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

        enforcer.postEntitlement(consumer, postHelper, e);
        verify(poolManagerMock, never()).createPool(any(Pool.class));
        verify(poolManagerMock, never()).updatePoolQuantity(any(Pool.class), anyInt());
View Full Code Here

        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", virtBonusPool.getProductAttribute("virt_limit")
            .getValue());

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

        virtBonusPool.setAttribute("host_limited", "true");
        virtBonusPool.setAttribute("virt_only", "true");
        virtBonusPool.setAttribute("virt_limit", "10");
        virtBonusPool.setAttribute("pool_derived", "true");

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

    @Test(expected = BadRequestException.class)
    public void migrateEntitlementDestinationConsumerFail() {
        ConsumerType ct = TestUtil.createConsumerType();
        ct.setManifest(true);
        Entitlement e = TestUtil.createEntitlement();
        Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct);
        e.setConsumer(sourceConsumer);
        e.setQuantity(25);

        when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
        when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);

        entResource.migrateEntitlement(e.getId(), consumer.getUuid(), 15);
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.Entitlement

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.