Package org.candlepin.model

Examples of org.candlepin.model.Product


    public void createPoolsForExistingSubscriptionsMasterExist() {
        PoolRules pRules = new PoolRules(manager, productCache,
            mockConfig, entitlementCurator);
        List<Subscription> subscriptions = Util.newList();
        List<Pool> pools = Util.newList();
        Product prod = TestUtil.createProduct();
        Set<Product> products = new HashSet<Product>();
        products.add(prod);
        productCache.addProducts(products);
        prod.setAttribute("virt_limit", "4");
        Subscription s = TestUtil.createSubscription(getOwner(), prod);
        subscriptions.add(s);
        when(mockSubAdapter.getSubscriptions(any(Owner.class))).thenReturn(
            subscriptions);
        when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
View Full Code Here


    public void createPoolsForExistingSubscriptionsBonusExist() {
        PoolRules pRules = new PoolRules(manager, productCache,
            mockConfig, entitlementCurator);
        List<Subscription> subscriptions = Util.newList();
        List<Pool> pools = Util.newList();
        Product prod = TestUtil.createProduct();
        Set<Product> products = new HashSet<Product>();
        products.add(prod);
        productCache.addProducts(products);
        prod.setAttribute("virt_limit", "4");
        Subscription s = TestUtil.createSubscription(getOwner(), prod);
        subscriptions.add(s);
        when(mockSubAdapter.getSubscriptions(any(Owner.class))).thenReturn(
            subscriptions);
        when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
View Full Code Here

            entCurMock);
    }

    protected Subscription createVirtLimitSub(String productId, int quantity,
        String virtLimit) {
        Product product = new Product(productId, productId);
        product.setAttribute("virt_limit", virtLimit);
        when(prodAdapter.getProductById(productId)).thenReturn(product);
        Subscription s = TestUtil.createSubscription(product);
        s.setQuantity(new Long(quantity));
        s.setId("subId");
        return s;
View Full Code Here

        pool.setId("fakeid" + TestUtil.randomInt());
        return pool;
    }

    protected Pool setupVirtLimitPool() {
        Product product = new Product(productId, "A virt_limit product");
        Pool pool = TestUtil.createPool(owner, product);
        pool.addAttribute(new PoolAttribute("virt_limit", "10"));
        pool.setId("fakeid" + TestUtil.randomInt());
        when(this.prodAdapter.getProductById(productId)).thenReturn(product);
        return pool;
View Full Code Here

    public void canExportProductConsumer() throws NoSuchMethodException {
        Entitlement entitlement = mock(Entitlement.class);
        Consumer consumer = mock(Consumer.class);
        ConsumerType consumerType = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);
        Set<PoolAttribute> attributes = new HashSet<PoolAttribute>();
        attributes.add(new PoolAttribute("pool_derived", "true"));


        when(entitlement.getPool()).thenReturn(pool);
        when(entitlement.getConsumer()).thenReturn(consumer);
        when(pool.getProductId()).thenReturn("12345");
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(attributes);
        when(consumer.getType()).thenReturn(consumerType);
        when(consumerType.getLabel()).thenReturn("system");

        assertTrue(exportRules.canExport(entitlement));
View Full Code Here

    public void canExportProductVirt() throws NoSuchMethodException {
        Entitlement entitlement = mock(Entitlement.class);
        Consumer consumer = mock(Consumer.class);
        ConsumerType consumerType = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);
        Set<PoolAttribute> attributes = new HashSet<PoolAttribute>();

        when(entitlement.getPool()).thenReturn(pool);
        when(entitlement.getConsumer()).thenReturn(consumer);
        when(pool.getProductId()).thenReturn("12345");
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(attributes);
        when(consumer.getType()).thenReturn(consumerType);
        when(consumerType.getLabel()).thenReturn("candlepin");

        assertTrue(exportRules.canExport(entitlement));
View Full Code Here

        Consumer c = mock(Consumer.class);
        PoolHelper ph = mock(PoolHelper.class);
        Entitlement e = mock(Entitlement.class);
        ConsumerType type = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);

        when(e.getPool()).thenReturn(pool);
        when(e.getConsumer()).thenReturn(c);
        when(c.getType()).thenReturn(type);
        when(type.isManifest()).thenReturn(true);
        when(pool.getProductId()).thenReturn("testProd");
        when(prodAdapter.getProductById(eq("testProd"))).thenReturn(product);
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(new HashSet<PoolAttribute>());

        assertEquals(ph, enforcer.postEntitlement(c, ph, e));
    }
View Full Code Here

        // Test with sockets to make sure that they are skipped.
        Consumer c = TestUtil.createConsumer();
        c.setFact("cpu.socket(s)", "12");
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        prod.setAttribute("sockets", "2");
        Pool p = TestUtil.createPool(prod);

        ValidationResult results = enforcer.preEntitlement(c, p, 1);
        assertNotNull(results);
        assertTrue(results.getErrors().isEmpty());
View Full Code Here

        c.setFact("cpu.core(s)_per_socket", "2");
        Set<ConsumerCapability> caps = new HashSet<ConsumerCapability>();
        c.setCapabilities(caps);
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        prod.setAttribute("cores", "2");
        Pool p = TestUtil.createPool(prod);

        ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BIND);
        assertNotNull(results);
        assertEquals(0, results.getWarnings().size());
View Full Code Here

        c.setFact("cpu.core(s)_per_socket", "2");
        Set<ConsumerCapability> caps = new HashSet<ConsumerCapability>();
        c.setCapabilities(caps);
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        prod.setAttribute("cores", "2");
        Pool p = TestUtil.createPool(prod);

        ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.LIST_POOLS);
        assertNotNull(results);
        assertEquals(0, results.getErrors().size());
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.