Package org.candlepin.model

Examples of org.candlepin.model.Entitlement


    @Test(expected = BadRequestException.class)
    public void migrateEntitlementSameOwnerFail() {
        ConsumerType ct = TestUtil.createConsumerType();
        ct.setManifest(true);
        Entitlement e = TestUtil.createEntitlement();
        Owner owner2 = new Owner("admin2");
        Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct);
        Consumer destConsumer = new Consumer("destination-consumer", "bill", owner2, 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(), 15);
    }
View Full Code Here


        Pool p = createPoolAndSub(theOwner, product,
            Long.valueOf(maxMembers), new Date(), expiry);

        for (int i = 0; i < currentMembers; i++) {
            Consumer c = createConsumer(theOwner);
            Entitlement e = createEntitlement(theOwner, c, p, null);
            e.setQuantity(1);
            entitlementCurator.create(e);
            p.getEntitlements().add(e);
            poolCurator.merge(p);
        }
        poolCurator.refresh(p);
View Full Code Here

        p.setAttribute("brand_type", "OS");
        Set<Product> prods = new HashSet<Product>(Arrays.asList(p));
        Pool pool = TestUtil.createPool(new Product("mkt", "MKT SKU"));
        pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
        Consumer consumer = new Consumer();
        Entitlement e = new Entitlement(pool, consumer, 10);

        List<org.candlepin.json.model.Product> certProds = util.createProducts(prods, "",
            new HashMap<String, EnvironmentContent>()new Consumer(), e);

        assertEquals(1, certProds.size());
View Full Code Here

        Set<String> possibleBrandNames = new HashSet<String>();
        for (Branding b : pool.getBranding()) {
            possibleBrandNames.add(b.getName());
        }
        Consumer consumer = new Consumer();
        Entitlement e = new Entitlement(pool, consumer, 10);

        List<org.candlepin.json.model.Product> certProds = util.createProducts(prods, "",
            new HashMap<String, EnvironmentContent>()new Consumer(), e);

        assertEquals(1, certProds.size());
View Full Code Here

        assertFalse(output.contains("FILTERMEPLEASE"));
    }

    @Test
    public void filterEntitlementConsumer() {
        Entitlement e = new Entitlement();
        Consumer c = new Consumer();
        IdentityCertificate cert = new IdentityCertificate();
        cert.setCert("FILTERMEPLEASE");
        cert.setKey("KEY");
        c.setIdCert(cert);
        e.setConsumer(c);

        context.put("entitlement", e);
        String output = objMapper.toJsonString(context);
        assertFalse(output.contains("consumer"));
    }
View Full Code Here

    @Test
    public void filterEntitlementCert() {
        List<Entitlement> allEnts = new LinkedList<Entitlement>();

        Entitlement e = new Entitlement();
        Set<EntitlementCertificate> entCerts = new HashSet<EntitlementCertificate>();
        EntitlementCertificate cert = new EntitlementCertificate();
        cert.setCert("FILTERME");
        cert.setKey("FILTERME");
        entCerts.add(cert);
        e.setCertificates(entCerts);

        allEnts.add(e);

        context.put("entitlements", allEnts);
        String output = objMapper.toJsonString(context);
View Full Code Here

    @Test
    public void bindByPoolString() throws EntitlementRefusedException {
        String poolid = "pool10";
        Pool pool = mock(Pool.class);
        Entitlement ent = mock(Entitlement.class);

        when(cc.findByUuid(eq("abcd1234"))).thenReturn(consumer);
        when(pm.find(eq(poolid))).thenReturn(pool);
        when(pm.entitleByPool(eq(consumer), eq(pool), eq(1))).thenReturn(ent);
View Full Code Here

    @Test
    public void bindByPool() throws EntitlementRefusedException {
        String poolid = "pool10";
        Pool pool = mock(Pool.class);
        Entitlement ent = mock(Entitlement.class);

        when(pm.find(eq(poolid))).thenReturn(pool);
        when(pm.entitleByPool(eq(consumer), eq(pool), eq(1))).thenReturn(ent);

        List<Entitlement> ents = entitler.bindByPool(poolid, consumer, 1);
View Full Code Here

    }

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

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

        job.toExecute(null);
        consumerCurator.refresh(consumer);
        assertEquals("valid", consumer.getEntitlementStatus());

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

    }

    @Test
    public void testActiveEntitlementJobNoChange() throws JobExecutionException {
        Pool p = createPoolAndSub(owner, prod, 5L, Util.yesterday(), Util.tomorrow());
        Entitlement ent = this.createEntitlement(owner, consumer, p,
                createEntitlementCertificate("entkey", "ecert"));
        // Already done
        ent.setUpdatedOnStart(true);
        entitlementCurator.create(ent);

        job.toExecute(null);

        // Unchanged
        assertTrue(entitlementCurator.find(ent.getId()).isUpdatedOnStart());
    }
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.