Package org.candlepin.model

Examples of org.candlepin.model.Entitlement


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

        consumer.setFact(SOCKET_FACT, "4");

        // Green now, but we will ask for suggested quantity on a date in the future:
        Entitlement e = createValidEntitlement(pool);
        e.setQuantity(4);

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

        consumer.setEntitlements(ents);
View Full Code Here


        consumer.setFact(SOCKET_FACT, "8");
        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());
        pool.setQuantity(10L);
        Product product1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, product1);
        Entitlement e = TestUtil.createEntitlement(owner, consumer, pool1,
            new EntitlementCertificate());

        Set<Entitlement> entSet = new HashSet<Entitlement>();
        entSet.add(e);
        pool1.setEntitlements(entSet);
        pool1.setProductAttribute("multi-entitlement", "yes", product1.getId());
        pool1.setProductAttribute("stacking_id", "2", product1.getId());
        pool1.setProductAttribute(SOCKET_ATTRIBUTE, "2", product1.getId());
        pool1.setQuantity(10L);

        // Consume 2 subscriptions with another stacking ID
        Entitlement toAdd = pool1.getEntitlements().iterator().next();
        toAdd.setQuantity(2);
        consumer.addEntitlement(toAdd);

        // Ensure the 2 attached entitlements do not cause the suggested quantity to change
        SuggestedQuantity suggested =
            quantityRules.getSuggestedQuantity(pool, consumer, new Date());
View Full Code Here

        Pool pool = TestUtil.createPool(owner, parentProduct, provided, subProduct.getId(),
            subProvidedProducts, 3);
        EntitlementCertificate cert = createEntitlementCertificate("my-test-key",
            "my-cert");
        Entitlement ent = TestUtil.createEntitlement(owner, consumer, pool, cert);
        ent.setQuantity(3);

        Reader reader = mock(Reader.class);
        when(om.readValue(reader, Entitlement.class)).thenReturn(ent);

        // Create our expected products
        Map<String, Product> productsById = new HashMap<String, Product>();
        productsById.put(parentProduct.getId(), parentProduct);
        productsById.put(pp1.getProductId(),
            TestUtil.createProduct(pp1.getProductId(), pp1.getProductName()));
        productsById.put(subProduct.getId(), subProduct);
        productsById.put(subProvided1.getProductId(), TestUtil.createProduct(
            subProvided1.getProductId(), subProvided1.getProductName()));

        Meta meta = new Meta();
        meta.setCdnLabel("test-cdn");
        Cdn testCdn = new Cdn("test-cdn",
            "Test CDN", "https://test.url.com");
        when(cdnCurator.lookupByLabel("test-cdn")).thenReturn(testCdn);

        Subscription sub = importer.importObject(om, reader, owner,
            productsById, consumerDto, meta);

        assertEquals(pool.getId(), sub.getUpstreamPoolId());
        assertEquals(consumer.getUuid(), sub.getUpstreamConsumerId());
        assertEquals(ent.getId(), sub.getUpstreamEntitlementId());

        assertEquals(owner, sub.getOwner());
        assertEquals(ent.getStartDate(), sub.getStartDate());
        assertEquals(ent.getEndDate(), sub.getEndDate());

        assertEquals(pool.getAccountNumber(), sub.getAccountNumber());
        assertEquals(pool.getContractNumber(), sub.getContractNumber());
        assertEquals(pool.getOrderNumber(), sub.getOrderNumber());

        assertEquals(ent.getQuantity().intValue(), sub.getQuantity().intValue());

        assertEquals(parentProduct, sub.getProduct());
        assertEquals(provided.size(), sub.getProvidedProducts().size());
        assertEquals(pp1.getProductId(), sub.getProvidedProducts().
            iterator().next().getId());
View Full Code Here

        Consumer consumer = mock(Consumer.class);
        when(consumer.getUuid()).thenReturn("357ec012");
        consumers.add(consumer);

        List<Entitlement> ents = new ArrayList<Entitlement>();
        Entitlement ent = mock(Entitlement.class);
        when(ent.getId()).thenReturn("ff8080812e9");
        ents.add(ent);

        ClientResponse<List<Pool>> prsp = mock(ClientResponse.class);
        ClientResponse<List<Consumer>> crsp = mock(ClientResponse.class);
        ClientResponse<List<Entitlement>> ersp = mock(ClientResponse.class);
View Full Code Here

    @Test (expected = RuntimeException.class)
    public void testExceptionFromCertGen() throws Exception {
        Consumer consumer = createConsumer();

        Entitlement e = Mockito.mock(Entitlement.class);
        Pool p = Mockito.mock(Pool.class);
        Subscription s = Mockito.mock(Subscription.class);
        when(e.getPool()).thenReturn(p);
        when(p.getSubscriptionId()).thenReturn("4444");

        when(mockedConsumerCurator.verifyAndLookupConsumer(consumer.getUuid())).thenReturn(
            consumer);
        when(mockedEntitlementCurator.find(eq("9999"))).thenReturn(e);
View Full Code Here

        // return null getFacts and ensure we don't blow up because of it
        when(consumer.getFacts()).thenReturn(null);
        consumers.add(consumer);

        List<Entitlement> ents = new ArrayList<Entitlement>();
        Entitlement ent = mock(Entitlement.class);
        when(ent.getId()).thenReturn("ff8080812e9");
        ents.add(ent);

        ClientResponse<List<Pool>> prsp = mock(ClientResponse.class);
        ClientResponse<List<Consumer>> crsp = mock(ClientResponse.class);
        ClientResponse<List<Entitlement>> ersp = mock(ClientResponse.class);
View Full Code Here

        p.setSourceSubscription(new SourceSubscription("112", "master"));

        // Mock a pool with a source entitlement:
        p.setAttribute("pool_derived", "true");
        p.setSourceStack(null);
        p.setSourceEntitlement(new Entitlement());

        pools.add(p);
        mockSubsList(subscriptions);

        mockPoolsList(pools);
View Full Code Here

        verify(this.mockPoolCurator, times(1)).delete(any(Pool.class));
    }

    @Test
    public void testLazyRegenerate() {
        Entitlement e = new Entitlement();
        manager.regenerateCertificatesOf(e, false, true);
        assertTrue(e.getDirty());
        verifyZeroInteractions(entCertAdapterMock);
    }
View Full Code Here

        verifyZeroInteractions(entCertAdapterMock);
    }

    @Test
    public void testLazyRegenerateForConsumer() {
        Entitlement e = new Entitlement();
        Consumer c = new Consumer();
        c.addEntitlement(e);
        manager.regenerateEntitlementCertificates(c, true);
        assertTrue(e.getDirty());
        verifyZeroInteractions(entCertAdapterMock);
    }
View Full Code Here

        ConsumerType type = consumerTypeCurator.lookupByLabel("system");
        Consumer consumer = new Consumer("test-consumer", "test-user", owner, type);
        consumerCurator.create(consumer);

        EntitlementCertificate cert = createEntitlementCertificate("fake", "fake");
        Entitlement entitlement = createEntitlement(owner, consumer, pool1, cert);
        entitlement.setQuantity(1);
        entitlementCurator.create(entitlement);

        OwnerInfo info = ownerInfoCurator.lookupByOwner(owner);

        Map<String, Integer> expectedConsumers = new HashMap<String, Integer>() {
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.