Package org.candlepin.model

Examples of org.candlepin.model.Entitlement


    @Test
    public void testActiveEntitlementJobStillInactive() throws JobExecutionException {
        // Future pool
        Pool p = createPoolAndSub(owner, prod, 5L, Util.tomorrow(), Util.addDaysToDt(10));
        Entitlement ent = this.createEntitlement(owner, consumer, p,
                createEntitlementCertificate("entkey", "ecert"));
        // Needs to be flipped, eventually
        ent.setUpdatedOnStart(false);
        entitlementCurator.create(ent);

        consumerCurator.refresh(consumer);
        assertFalse("valid".equals(consumer.getEntitlementStatus()));

        job.toExecute(null);
        consumerCurator.refresh(consumer);
        // still not valid.  Probably not even set, but that doesn't matter
        assertFalse("valid".equals(consumer.getEntitlementStatus()));

        // Should not have changed
        assertFalse(entitlementCurator.find(ent.getId()).isUpdatedOnStart());
    }
View Full Code Here


        owner = new Owner("Test Owner " + TestUtil.randomInt());
        product = TestUtil.createProduct();
        pool = TestUtil.createPool(owner, product);

        consumer = TestUtil.createConsumer(owner);
        Entitlement e = TestUtil.createEntitlement(owner, consumer, pool,
            new EntitlementCertificate());

        Set<Entitlement> entSet = new HashSet<Entitlement>();
        entSet.add(e);
View Full Code Here

        pool.setProductAttribute("multi-entitlement", "yes", product.getId());
        pool.setProductAttribute("stacking_id", "1", product.getId());
    }

    private Entitlement createValidEntitlement(Pool p) {
        Entitlement e = TestUtil.createEntitlement(owner, consumer, p, null);

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.DATE, 1);

        Date dayFromNow = cal.getTime();

        cal.add(Calendar.DATE, -2);
        Date dayAgo = cal.getTime();

        e.setCreated(dayAgo);
        p.setEndDate(dayFromNow);
        return e;
    }
View Full Code Here

    @Test
    public void testPhysicalAccountsForCurrentlyConsumed() {
        consumer.setFact(SOCKET_FACT, "4");
        pool.setProductAttribute(SOCKET_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 serverPool = TestUtil.createPool(owner, server, 10);
        Pool hyperPool = TestUtil.createPool(owner, hypervisor, 10);
        serverPool.setId("POOL-ID1");
        hyperPool.setId("Pool-ID2");

        Entitlement entitlement = TestUtil.createEntitlement();
        entitlement.setPool(hyperPool);
        entitlement.setQuantity(1); // compliant

        // The hypervisor must be installed and entitled on the system for autobind
        // to pick up the unlimited guest_limit
        compliance.addCompliantProduct(hypervisor.getId(), entitlement);
View Full Code Here

        Response rsp = consumerResource.bind(
            consumer.getUuid(), pool.getId().toString(), null, 1, null,
            null, false, null, null);

        List<Entitlement> resultList = (List<Entitlement>) rsp.getEntity();
        Entitlement ent = resultList.get(0);
        Set<EntitlementCertificate> entCertsBefore = ent.getCertificates();

        cr.regenerateEntitlementCertificates(this.consumer.getUuid(),
            ent.getId(), true);
        Set<EntitlementCertificate> entCertsAfter = ent.getCertificates();

        assertFalse(entCertsBefore.equals(entCertsAfter));
    }
View Full Code Here

            1000L, TestUtil.createDate(2009, 11, 30),
            TestUtil.createDate(2015, 11, 30));
        entityManager().persist(pool.getOwner());
        entityManager().persist(pool);

        Entitlement e1 = createEntitlement(pool, consumer);
        Entitlement e2 = createEntitlement(pool, consumer);
        Entitlement e3 = createEntitlement(pool, consumer);
        entityManager().persist(e1);
        entityManager().persist(e2);
        entityManager().persist(e3);

        consumer.addEntitlement(e1);
View Full Code Here

        Consumer lookedUp = consumerCurator.find(consumer.getId());
        assertEquals(3, lookedUp.getEntitlements().size());
    }

    private Entitlement createEntitlement(Pool pool, Consumer c) {
        Entitlement e = new Entitlement(pool, c, 1);
        return e;
    }
View Full Code Here

        productCurator.create(providedProduct2);
    }

    @Test
    public void testCompareTo() {
        Entitlement e1 = TestUtil.createEntitlement();
        Entitlement e2 = TestUtil.createEntitlement(e1.getOwner(), e1.getConsumer(), e1.getPool(), null);
        e2.getCertificates().addAll(e1.getCertificates());

        assertTrue(e1.equals(e2));
        assertEquals(0, e1.compareTo(e2));
    }
View Full Code Here

        testPool.addProvidedProduct(p2);
        poolCurator.create(testPool);

        EntitlementCertificate cert = createEntitlementCertificate("key", "certificate");

        Entitlement ent = createEntitlement(owner, consumer, testPool, cert);
        entitlementCurator.create(ent);

        return ent;
    }
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.