Package org.candlepin.model

Examples of org.candlepin.model.ProductAttribute


    }

    @Test
    public void testQuantityIncrement() {
        Product product2 = new Product("blah", "blah");
        product2.addAttribute(new ProductAttribute("instance_multiplier", "12"));
        productCurator.create(product2);

        Pool pool2 = createPoolAndSub(owner1, product2, 500L,
            TestUtil.createDate(2000, 1, 1), TestUtil.createDate(3000, 1, 1));
View Full Code Here


        return Math.abs(RANDOM.nextInt());
    }

    public static Product createProduct(String id, String name) {
        Product rhel = new Product(id, name);
        ProductAttribute a1 = new ProductAttribute("a1", "a1");
        rhel.addAttribute(a1);

        ProductAttribute a2 = new ProductAttribute("a2", "a2");
        rhel.addAttribute(a2);

        return rhel;
    }
View Full Code Here

        Pool pool = pools.get(0);

        // Remove the instance multiplier attribute entirely, pool quantity should
        // revert to half of what it was. No existing entitlements need to be adjusted,
        // we will let a (future) overconsumption routine handle that.
        ProductAttribute pa = s.getProduct().getAttribute("instance_multiplier");
        s.getProduct().getAttributes().remove(pa);

        List<Pool> existingPools = new LinkedList<Pool>();
        existingPools.add(pool);
        List<PoolUpdate> updates = poolRules.updatePools(s, existingPools);
View Full Code Here

        consumer = TestUtil.createConsumer(standardSystemType, owner);
        consumerCurator.create(consumer);

        product = TestUtil.createProduct();
        product.addAttribute(new ProductAttribute("support_level", DEFAULT_SERVICE_LEVEL));
        productCurator.create(product);

        pool = createPoolAndSub(owner, product, 10L,
            TestDateUtil.date(2010, 1, 1), TestDateUtil.date(2020, 12, 31));
    }
View Full Code Here

        data.put("b", "2");
        ObjectMapper mapper = new ObjectMapper();
        String jsonData = mapper.writeValueAsString(data);

        Product prod = new Product("cptest-label", "My Product");
        ProductAttribute a = new ProductAttribute("content_sets", jsonData);
        prod.addAttribute(a);
        productCurator.create(prod);
        attributeCurator.create(a);

        Product lookedUp = productCurator.find(prod.getId());
View Full Code Here

        ObjectMapper mapper = new ObjectMapper();
        String jsonData = mapper.writeValueAsString(data);

        Product prod = new Product("cptest-label", "My Product");
        ProductAttribute a = new ProductAttribute("content_sets", jsonData);
        prod.addAttribute(a);
        productCurator.create(prod);
        attributeCurator.create(a);

        Product lookedUp = productCurator.find(prod.getId());
View Full Code Here

    }

    private Product createTestProduct() {
        Product p = TestUtil.createProduct("testProductId", "Test Product");

        ProductAttribute a1 = new ProductAttribute("a1", "a1");
        p.addAttribute(a1);

        ProductAttribute a2 = new ProductAttribute("a2", "a2");
        p.addAttribute(a2);

        ProductAttribute a3 = new ProductAttribute("a3", "a3");
        p.addAttribute(a3);

        p.setMultiplier(1L);
        return p;
    }
View Full Code Here

        modified.setName(newName);

        // Hack up the attributes, keep a1, skip a2, modify a3, add a4:
        Set<ProductAttribute> newAttributes = new HashSet<ProductAttribute>();
        newAttributes.add(modified.getAttribute("a1"));
        ProductAttribute a3 = modified.getAttribute("a3");
        a3.setValue("a3-modified");
        a3.setProduct(modified);
        newAttributes.add(a3);
        ProductAttribute a4 = new ProductAttribute("a4", "a4");
        a4.setProduct(modified);
        newAttributes.add(a4);
        modified.setAttributes(newAttributes);

        int initialAttrCount = attributeCurator.listAll().size();
        productCurator.createOrUpdate(modified);
View Full Code Here

    }

    @Test
    public void testProductAttributeValidationSuccessCreate() {
        Product original = createTestProduct();
        original.addAttribute(new ProductAttribute("product.count", "1"));
        original.addAttribute(new ProductAttribute("product.pos_count", "5"));
        original.addAttribute(new ProductAttribute("product.long_multiplier",
            (new Long(Integer.MAX_VALUE * 1000)).toString()));
        original.addAttribute(new ProductAttribute("product.long_pos_count", "23"));
        original.addAttribute(new ProductAttribute("product.bool_val_str", "true"));
        original.addAttribute(new ProductAttribute("product.bool_val_num", "0"));
        productCurator.create(original);
        assertTrue(original.getId() != null);
    }
View Full Code Here

    }

    @Test(expected = BadRequestException.class)
    public void testProductAttributeCreationFailBadInt() {
        Product original = createTestProduct();
        original.addAttribute(new ProductAttribute("product.count", "1.0"));
        productCurator.create(original);
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.ProductAttribute

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.