Package org.candlepin.model

Examples of org.candlepin.model.Product


        assertEquals(new Long(200), update.getPool().getQuantity());
    }

    private Subscription createInstanceBasedSub(String productId, int quantity,
        int instanceMultiplier, boolean exported) {
        Product product = new Product(productId, productId);
        product.setAttribute("instance_multiplier",
            Integer.toString(instanceMultiplier));
        when(productAdapterMock.getProductById(productId)).thenReturn(product);
        Subscription s = TestUtil.createSubscription(product);
        if (exported) {
            s.setUpstreamPoolId("SOMETHING");
View Full Code Here


        return keys;
    }

    @Test
    public void registerWithKeyWithPoolAndInstalledProductsAutoAttach() {
        Product prod = TestUtil.createProduct();
        String[] prodIds = new String[]{prod.getId()};

        Pool pool = TestUtil.createPool(owner, prod);
        pool.setId("id-string");
        List<String> poolIds = new ArrayList<String>();
        poolIds.add(pool.getId());

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.addPool(pool, 0L);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod.getId(), prod.getName());
        cips.add(cip);
        consumer.setInstalledProducts(cips);

        AutobindData ad = new AutobindData(consumer).withPools(poolIds).forProducts(prodIds);
        consumerBindUtil.handleActivationKeys(consumer, keys);
View Full Code Here

        verify(entitler).bindByProducts(eq(ad));
    }

    @Test
    public void registerWithKeyWithInstalledProductsAutoAttach() {
        Product prod = TestUtil.createProduct();
        String[] prodIds = new String[]{prod.getId()};

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod.getId(), prod.getName());
        cips.add(cip);
        consumer.setInstalledProducts(cips);

        AutobindData ad = new AutobindData(consumer).forProducts(prodIds);
        consumerBindUtil.handleActivationKeys(consumer, keys);
View Full Code Here

    }

    @Test
    public void registerWithKeyWithInstalledProductsPlusAutoAttach() {
        // installed product
        Product prod1 = TestUtil.createProduct();
        // key product
        Product prod2 = TestUtil.createProduct();
        String[] prodIds = new String[]{prod1.getId(), prod2.getId()};

        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.addProduct(prod2);
View Full Code Here

    public void registerFailWithNoGoodKeyPool() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool ghost = TestUtil.createPool(owner, prod1, 5);
        ghost.setId("ghost-pool");
        key1.addPool(ghost, 10L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
View Full Code Here

    public void registerPassWithOneGoodKeyPool() {
        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key1.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
View Full Code Here

        ActivationKey key1 = new ActivationKey("key1", owner);
        ActivationKey key2 = new ActivationKey("key2", owner);
        keys.add(key1);
        keys.add(key2);

        Product prod1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, prod1, 5);
        pool1.setId("pool1");
        key1.addPool(pool1, 10L);
        Product prod2 = TestUtil.createProduct();
        Pool pool2 = TestUtil.createPool(owner, prod2, 5);
        pool2.setId("pool2");
        key1.addPool(pool2, 10L);
        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key2.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
View Full Code Here

    }

    // This exception should mention wrapping a MissingFactException
    @Test(expected = RuleExecutionException.class)
    public void testRuleFailsWhenConsumerDoesntHaveFact() {
        Product product = new Product("a-product", "A product for testing");
        product.setAttribute(PRODUCT_CPULIMITED, "2");
        productCurator.create(product);

        when(this.productAdapter.getProductById("a-product")).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(
View Full Code Here

        sppSet.add(spp);

        Set<Entitlement> entitlements = new HashSet<Entitlement>();
        entitlements.add(ent);

        Product prod = new Product("12345", "RHEL Product");
        prod.setMultiplier(1L);
        prod.setCreated(new Date());
        prod.setUpdated(new Date());
        prod.setHref("http://localhost");
        prod.setAttributes(Collections.EMPTY_SET);

        Product prod1 = new Product("MKT-prod", "RHEL Product");
        prod1.setMultiplier(1L);
        prod1.setCreated(new Date());
        prod1.setUpdated(new Date());
        prod1.setHref("http://localhost");
        prod1.setAttributes(Collections.EMPTY_SET);

        Product subProduct = new Product("MKT-sub-prod", "Sub Product");
        subProduct.setMultiplier(1L);
        subProduct.setCreated(new Date());
        subProduct.setUpdated(new Date());
        subProduct.setHref("http://localhost");
        subProduct.setAttributes(Collections.EMPTY_SET);

        Product subProvidedProduct = new Product("332211", "Sub Product");
        subProvidedProduct.setMultiplier(1L);
        subProvidedProduct.setCreated(new Date());
        subProvidedProduct.setUpdated(new Date());
        subProvidedProduct.setHref("http://localhost");
        subProvidedProduct.setAttributes(Collections.EMPTY_SET);

        ProductCertificate pcert = new ProductCertificate();
        pcert.setKey("euh0876puhapodifbvj094");
        pcert.setCert("hpj-08ha-w4gpoknpon*)&^%#");
        pcert.setCreated(new Date());
        pcert.setUpdated(new Date());

        when(pp.getProductId()).thenReturn("12345");
        when(pool.getProvidedProducts()).thenReturn(ppset);
        when(pool.getProductId()).thenReturn("MKT-prod");

        when(pool.getDerivedProvidedProducts()).thenReturn(sppSet);
        when(pool.getDerivedProductId()).thenReturn(subProduct.getId());
        when(spp.getProductId()).thenReturn(subProvidedProduct.getId());

        when(ent.getPool()).thenReturn(pool);
        when(mrules.getRules()).thenReturn("foobar");
        when(pki.getSHA256WithRSAHash(any(InputStream.class))).thenReturn(
            "signature".getBytes());
View Full Code Here

        }
        else {
            if (product.getId() == null || product.getId().trim().equals("")) {
                product.setId(idGenerator.generateId());
            }
            Product newProduct = prodCurator.create(product);
            return newProduct;
        }
    }
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.