Package org.candlepin.model

Examples of org.candlepin.model.Subscription


    }

    protected Subscription createSubscription() {
        Product p = TestUtil.createProduct();
        productCurator.create(p);
        Subscription sub = new Subscription(createOwner(),
                                            p, new HashSet<Product>(),
                                            1000L,
                                            TestUtil.createDate(2000, 1, 1),
                                            TestUtil.createDate(2010, 1, 1),
                                            TestUtil.createDate(2000, 1, 1));
View Full Code Here


    @Test
    public void copyProductAttributesOntoPoolRemovesNonExistingAttribute() {
        Product targetProduct = TestUtil.createProduct();
        targetProduct.getAttributes().clear();
        Subscription sourceSub = TestUtil.createSubscription(targetProduct);
        Pool targetPool = TestUtil.createPool(targetProduct);

        targetPool.setProductAttribute("A1", "V1", targetProduct.getId());

        PoolHelper ph = new PoolHelper(pm, productCache, null);
        when(psa.getProductById(targetProduct.getId())).thenReturn(targetProduct);
        assertTrue("Update expected.",
            ph.copyProductAttributesOntoPool(sourceSub.getProduct().getId(), targetPool));
        assertTrue(targetPool.getProductAttributes().isEmpty());
    }
View Full Code Here

        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());

        assertEquals(subProduct, sub.getDerivedProduct());
        assertEquals(1, sub.getDerivedProvidedProducts().size());
        assertEquals(subProvided1.getProductId(), sub.getDerivedProvidedProducts().
            iterator().next().getId());

        assertNotNull(sub.getCertificate());
        CertificateSerial serial = sub.getCertificate().getSerial();
        assertEquals(cert.getSerial().isCollected(), serial.isCollected());
        assertEquals(cert.getSerial().getExpiration(), serial.getExpiration());
        assertEquals(cert.getSerial().getCreated(), serial.getCreated());
        assertEquals(cert.getSerial().getUpdated(), serial.getUpdated());

        assertEquals(sub.getCdn().getLabel(), meta.getCdnLabel());
    }
View Full Code Here

    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);
View Full Code Here

        productCurator.create(childProduct);
        productCurator.create(parentProduct);

        Set<Product> providedProducts = new HashSet<Product>();
        providedProducts.add(childProduct);
        s1 = new Subscription(owner, parentProduct, providedProducts, 100L,
                TestUtil.createDate(2010, 2, 8), TestUtil.createDate(2050, 2, 8),
                TestUtil.createDate(2010, 2, 1));

        subCurator.create(s1);
View Full Code Here

        adapter = injector.getInstance(DefaultSubscriptionServiceAdapter.class);
    }

    @Test
    public void testGetSubscription() {
        Subscription s = adapter.getSubscription(s1.getId());
        assertNotNull(s);
        assertEquals(Long.valueOf(100), s.getQuantity());

        s = adapter.getSubscription("-15");
        assertNull(s);
    }
View Full Code Here

    public void testLookupSubscriptionByProduct() {
        Owner owner = createOwner();
        Product product = TestUtil.createProduct();
        productCurator.create(product);

        Subscription sub = TestUtil.createSubscription(owner, product);
        adapter.createSubscription(sub);

        List<Subscription> results = adapter.getSubscriptions(product);

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

        Owner owner = createOwner();

        Product product = TestUtil.createProduct();
        productCurator.create(product);

        Subscription sub = TestUtil.createSubscription(owner, product);
        adapter.createSubscription(sub);

        Subscription sub2 = TestUtil.createSubscription(owner, product);
        adapter.createSubscription(sub2);

        List<Subscription> results = adapter.getSubscriptions(product);
        assertEquals(2, results.size());
        assertTrue(results.contains(sub));
View Full Code Here

        Owner owner2 = createOwner();

        Product product = TestUtil.createProduct();
        productCurator.create(product);

        Subscription sub = TestUtil.createSubscription(owner, product);
        adapter.createSubscription(sub);

        Subscription sub2 = TestUtil.createSubscription(owner2, product);
        adapter.createSubscription(sub2);

        List<Subscription> results = adapter.getSubscriptions(product);
        assertEquals(2, results.size());
        assertTrue(results.contains(sub));
View Full Code Here

        productCurator.create(product);
        productCurator.create(provided);

        Set<Product> providedProducts = new HashSet<Product>();
        providedProducts.add(provided);
        Subscription sub = TestUtil.createSubscription(owner, product, providedProducts);
        adapter.createSubscription(sub);

        List<Subscription> results = adapter.getSubscriptions(provided);
        assertEquals(1, results.size());
        assertTrue(results.contains(sub));
View Full Code Here

TOP

Related Classes of org.candlepin.model.Subscription

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.