Package org.candlepin.model

Examples of org.candlepin.model.Entitlement


    // sunny test - real rules not invoked here. Can only be sure the counts are recorded.
    // Rule tests already exist for quantity filter.
    // Will use spec tests to see if quantity rules are followed in this scenario.
    @Test
    public void testEntitlementQuantityChange() throws EntitlementRefusedException {
        Entitlement ent = poolManager.entitleByPool(consumer, pool, 3);
        assertTrue(ent.getQuantity() == 3);
        poolManager.adjustEntitlementQuantity(consumer, ent, 5);
        Entitlement ent2 = entitlementCurator.find(ent.getId());
        assertTrue(ent2.getQuantity() == 5);
        Pool pool2 = poolCurator.find(pool.getId());
        assertTrue(pool2.getConsumed() == 5);
        assertTrue(pool2.getEntitlements().size() == 1);
    }
View Full Code Here


        assertEquals(PoolType.NORMAL, pool.getType());

        pool.setAttribute("pool_derived", "true");
        assertEquals(PoolType.BONUS, pool.getType());

        pool.setSourceEntitlement(new Entitlement());
        assertEquals(PoolType.ENTITLEMENT_DERIVED, pool.getType());

        pool.setSourceEntitlement(null);
        pool.setSourceStack(new SourceStack(new Consumer(), "something"));
        assertEquals(PoolType.STACK_DERIVED, pool.getType());
View Full Code Here

    public void testVirtAccountsForCurrentlyConsumed() {
        consumer.setFact(IS_VIRT, "true");
        consumer.setFact(CORES_FACT, "4");
        pool.setProductAttribute(VCPU_ATTRIBUTE, "1", product.getId());

        Entitlement e = createValidEntitlement(pool);
        e.setQuantity(2);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(e);

        consumer.setEntitlements(ents);
View Full Code Here

        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());

        Product product2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, product2);

        Entitlement e = createValidEntitlement(pool2);
        e.setQuantity(2);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(e);

        consumer.setEntitlements(ents);
View Full Code Here

    public void testCalculatedValueIsZeroWhenNegativeIsCalculated() {
        consumer.setFact(IS_VIRT, "");
        consumer.setFact(SOCKET_FACT, "4");
        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());

        Entitlement e = createValidEntitlement(pool);
        e.setQuantity(1000);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(e);

        consumer.setEntitlements(ents);
View Full Code Here

    public void testTotalConsumedDoesNotIncludeFutureEntitlements() {
        consumer.setFact(IS_VIRT, "");
        consumer.setFact(SOCKET_FACT, "4");
        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());

        Entitlement e = TestUtil.createEntitlement(owner, consumer, pool, null);
        pool.setStartDate(TestUtil.createDate(9000, 1, 1));
        pool.setEndDate(TestUtil.createDate(9001, 1, 1));
        e.setQuantity(2);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(e);

        consumer.setEntitlements(ents);
View Full Code Here

        currentPool.setProductAttribute("stacking_id", "1", product.getId());

        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());
        currentPool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());

        Entitlement currentEntitlement =
            TestUtil.createEntitlement(owner, consumer, currentPool, null);
        currentEntitlement.setQuantity(2);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(currentEntitlement);
        consumer.setEntitlements(ents);
View Full Code Here

    @Test
    public void testRevocation() throws Exception {
        AutobindData data = AutobindData.create(parentSystem).on(new Date())
                .forProducts(new String [] {monitoring.getId()});
        Entitlement e = poolManager.entitleByProducts(data).get(0);
        poolManager.revokeEntitlement(e);

        List<Entitlement> entitlements = entitlementCurator.listByConsumer(parentSystem);
        assertTrue(entitlements.isEmpty());
    }
View Full Code Here

    public void testConsumeQuantity() throws Exception {
        Pool monitoringPool = poolCurator.listByOwnerAndProduct(o,
            monitoring.getId()).get(0);
        assertEquals(Long.valueOf(5), monitoringPool.getQuantity());

        Entitlement e = poolManager.entitleByPool(parentSystem, monitoringPool, 3);
        assertNotNull(e);
        assertEquals(Long.valueOf(3), monitoringPool.getConsumed());

        poolManager.revokeEntitlement(e);
        assertEquals(Long.valueOf(0), monitoringPool.getConsumed());
View Full Code Here

        futurePool.setProductAttribute(SOCKET_ATTRIBUTE, "1", product.getId());

        consumer.setFact(SOCKET_FACT, "4");

        // Green in future but we have nothing now:
        Entitlement e = createValidEntitlement(futurePool);
        e.setQuantity(4);

        Set<Entitlement> ents = new HashSet<Entitlement>();
        ents.add(e);

        consumer.setEntitlements(ents);
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.