Package org.candlepin.model

Examples of org.candlepin.model.Product


        assertTrue(productCurator.productHasSubscriptions(derivedProvidedProduct));
    }

    @Test
    public void ensureDoesNotHaveSubscription() {
        Product doesNotHave = TestUtil.createProduct();
        productCurator.create(doesNotHave);
        assertFalse(productCurator.productHasSubscriptions(doesNotHave));
    }
View Full Code Here


        assertFalse(productCurator.productHasSubscriptions(doesNotHave));
    }

    @Test
    public void testSaveOrUpdateProductNoDuplicateProdContent() {
        Product p = createTestProduct();
        Content content = new Content("best-content", "best-content",
            "best-content", "yum", "us", "here", "here", "test-arch");
        p.addContent(content);
        contentCurator.create(content);
        productCurator.createOrUpdate(p);

        p = createTestProduct();
        // The content isn't quite the same.  We just care about matching
        // product ids with content ids
        content = new Content("best-content", "best-content",
            "best-content", "yum", "us", "here", "differnet", "test-arch");
        p.addContent(content);
        productCurator.createOrUpdate(p);

        Product result = productCurator.find(p.getId());
        assertEquals(1, result.getProductContent().size());
    }
View Full Code Here

    @Test
    public void concurrentCreationOfEntitlementsShouldWorkIfUnderMaxMemberLimit()
        throws Exception {
        Long numAvailEntitlements = 2L;

        Product newProduct = TestUtil.createProduct();
        newProduct.addAttribute(new ProductAttribute("multi-entitlement", "yes"));
        productCurator.create(newProduct);

        Pool consumerPool = createPoolAndSub(owner, newProduct,
            numAvailEntitlements, TestUtil.createDate(2009, 11, 30),
            TestUtil.createDate(2050, 11, 30));
View Full Code Here

    @Test(expected = EntitlementRefusedException.class)
    public void concurrentCreationOfEntitlementsShouldFailIfOverMaxMemberLimit()
        throws Exception {
        Long numAvailEntitlements = 1L;

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

        Pool consumerPool = createPoolAndSub(owner, newProduct, numAvailEntitlements,
            TestUtil.createDate(2009, 11, 30), TestUtil.createDate(2050, 11, 30));
        poolCurator.create(consumerPool);
View Full Code Here

    @Test
    public void testLookupMultipleOwnersByMultipleActiveProducts() {
        Owner owner = createOwner();
        Owner owner2 = createOwner();

        Product product = TestUtil.createProduct();
        Product provided = TestUtil.createProduct();
        Product product2 = TestUtil.createProduct();
        Product provided2 = TestUtil.createProduct();
        productCurator.create(product);
        productCurator.create(provided);
        productCurator.create(product2);
        productCurator.create(provided2);

        associateProductToOwner(owner, product, provided);
        associateProductToOwner(owner2, product2, provided2);

        List<String> productIds = new ArrayList<String>();
        productIds.add(provided.getId());
        productIds.add(provided2.getId());
        List<Owner> results = ownerCurator.lookupOwnersByActiveProduct(productIds);

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

    @Test
    public void testLookupOwnerByActiveProduct() {
        Owner owner = createOwner();

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

        associateProductToOwner(owner, product, provided);

        List<String> productIds = new ArrayList<String>();
        productIds.add(provided.getId());
        List<Owner> results = ownerCurator.lookupOwnersByActiveProduct(productIds);

        assertEquals(1, results.size());
        assertEquals(owner, results.get(0));
    }
View Full Code Here

    @Test
    public void testLookupOwnersByActiveProductWithExpiredEntitlements() {
        Owner owner = createOwner();

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

        Set<ProvidedProduct> providedProducts = new HashSet<ProvidedProduct>();
        ProvidedProduct providedProduct = new ProvidedProduct(
            provided.getId(), "Test Provided Product");
        providedProducts.add(providedProduct);

        // Create pool with end date in the past.
        Pool pool = new Pool(owner, product.getId(), product.getName(),
            providedProducts, Long.valueOf(5), TestUtil.createDate(2009,
                11, 30), TestUtil.createDate(2010, 11, 30), "SUB234598S",
            "ACC123", "ORD222");

        providedProduct.setPool(pool);
        poolCurator.create(pool);

        Consumer consumer = createConsumer(owner);
        consumerCurator.create(consumer);

        EntitlementCertificate cert = createEntitlementCertificate("key", "certificate");
        Entitlement ent = createEntitlement(owner, consumer, pool, cert);
        entitlementCurator.create(ent);

        List<String> productIds = new ArrayList<String>();
        productIds.add(provided.getId());
        List<Owner> results = ownerCurator.lookupOwnersByActiveProduct(productIds);

        assertTrue(results.isEmpty());
    }
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void normalCreate() {

        Product prod = new Product("cptest-label", "My Product");
        productCurator.create(prod);

        List<Product> results = entityManager().createQuery(
                "select p from Product as p").getResultList();
        assertEquals(5, results.size());
View Full Code Here

    }

    @Test(expected = PersistenceException.class)
    public void nameRequired() {

        Product prod = new Product("someproductlabel", null);
        productCurator.create(prod);

    }
View Full Code Here

    }

    @Test(expected = PersistenceException.class)
    public void labelRequired() {

        Product prod = new Product(null, "My Product Name");
        productCurator.create(prod);
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.Product

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.