Package org.candlepin.model

Examples of org.candlepin.model.Pool


        when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, "unlimited");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool physicalPool = pools.get(0);
        physicalPool.setId("physical");
        Pool virtBonusPool = pools.get(1);
        virtBonusPool.setId("virt");

        assertEquals(new Long(10), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());

        // Quantity on bonus pool should be -1:
        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", virtBonusPool.getProductAttribute("virt_limit")
            .getValue());

        Entitlement e = new Entitlement(physicalPool, consumer, 1);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);
        List<Pool> poolList = new ArrayList<Pool>();
View Full Code Here


        when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, "unlimited");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool physicalPool = pools.get(0);
        physicalPool.setId("physical");
        Pool virtBonusPool = pools.get(1);
        virtBonusPool.setId("virt");

        assertEquals(new Long(10), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());

        // Quantity on bonus pool should be -1:
        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", virtBonusPool.getProductAttribute("virt_limit")
            .getValue());

        Entitlement e = new Entitlement(physicalPool, consumer, 1);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);
View Full Code Here

        consumer.setType(new ConsumerType(ConsumerTypeEnum.CANDLEPIN));
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, "unlimited");
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(2, pools.size());

        Pool physicalPool = pools.get(0);
        physicalPool.setId("physical");
        Pool virtBonusPool = pools.get(1);
        virtBonusPool.setId("virt");

        assertEquals(new Long(10), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());

        // Quantity on bonus pool should be -1:
        assertEquals(new Long(-1), virtBonusPool.getQuantity());
        assertEquals("true", virtBonusPool.getAttributeValue("virt_only"));
        assertEquals("unlimited", virtBonusPool.getProductAttribute("virt_limit")
            .getValue());

        Entitlement e = new Entitlement(physicalPool, consumer, 10);
        physicalPool.setConsumed(10L);
        physicalPool.setExported(10L);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);
        List<Pool> poolList = new ArrayList<Pool>();
        poolList.add(virtBonusPool);
        when(poolManagerMock.lookupBySubscriptionId(eq(physicalPool.getSubscriptionId())))
            .thenReturn(poolList);

        enforcer.postEntitlement(consumer, postHelper, e);
        verify(poolManagerMock).setPoolQuantity(eq(virtBonusPool), eq(0L));
        virtBonusPool.setQuantity(0L);

        enforcer.postUnbind(consumer, postHelper, e);
        verify(poolManagerMock).setPoolQuantity(eq(virtBonusPool), eq(-1L));
    }
View Full Code Here

    @Test
    public void hostedVirtLimitDoesNotAlterQuantitiesForHostLimited() {
        when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        consumer.setType(new ConsumerType(ConsumerTypeEnum.CANDLEPIN));

        Pool virtBonusPool = setupVirtLimitPool();
        virtBonusPool.setQuantity(100L);
        virtBonusPool.setAttribute("host_limited", "true");
        virtBonusPool.setAttribute("virt_only", "true");
        virtBonusPool.setAttribute("virt_limit", "10");
        virtBonusPool.setAttribute("pool_derived", "true");

        Entitlement e = new Entitlement(virtBonusPool, consumer, 1);
        PoolHelper postHelper = new PoolHelper(poolManagerMock, productCache, e);
        List<Pool> poolList = new ArrayList<Pool>();
        poolList.add(virtBonusPool);
        when(poolManagerMock.lookupBySubscriptionId(eq(virtBonusPool.getSubscriptionId())))
            .thenReturn(poolList);

        enforcer.postEntitlement(consumer, postHelper, e);
        verify(poolManagerMock, never()).updatePoolQuantity(eq(virtBonusPool), eq(-10L));
View Full Code Here

        config.setProperty(ConfigProperties.SYNC_WORK_DIR, "/tmp/");
        Consumer consumer = mock(Consumer.class);
        Entitlement ent = mock(Entitlement.class);
        ProvidedProduct pp = mock(ProvidedProduct.class);
        DerivedProvidedProduct spp = mock(DerivedProvidedProduct.class);
        Pool pool = mock(Pool.class);
        Rules mrules = mock(Rules.class);
        Principal principal = mock(Principal.class);
        IdentityCertificate idcert = new IdentityCertificate();

        Set<ProvidedProduct> ppset = new HashSet<ProvidedProduct>();
        ppset.add(pp);

        Set<DerivedProvidedProduct> sppSet = new HashSet<DerivedProvidedProduct>();
        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(
View Full Code Here

        return TestDateUtil.date(year, month, day);
    }

    private Pool entitlementPoolWithMembersAndExpiration(Owner theOwner, Product product,
        final int currentMembers, final int maxMembers, Date expiry) {
        Pool p = createPoolAndSub(theOwner, product,
            Long.valueOf(maxMembers), new Date(), expiry);

        for (int i = 0; i < currentMembers; i++) {
            Consumer c = createConsumer(theOwner);
            Entitlement e = createEntitlement(theOwner, c, p, null);
            e.setQuantity(1);
            entitlementCurator.create(e);
            p.getEntitlements().add(e);
            poolCurator.merge(p);
        }
        poolCurator.refresh(p);
        return p;
    }
View Full Code Here

        return toReturn;
    }

    public Set<X509ExtensionWrapper> subscriptionExtensions(Entitlement ent) {
        Pool pool = ent.getPool();
        SimpleDateFormat iso8601DateFormat = Util.getUTCDateFormat();
        Set<X509ExtensionWrapper> toReturn = new LinkedHashSet<X509ExtensionWrapper>();
        // Subscription/order info
        // need the sub product name, not id here
        // NOTE: order ~= subscription
        // entitlement == entitlement

        String subscriptionOid = OIDUtil.REDHAT_OID + "." +
            OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.ORDER_NAMESPACE_KEY);
        if (pool.getProductId() != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NAME_KEY), false, ent
                .getPool().getProductName()));
        }
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NUMBER_KEY), false, pool
            .getOrderNumber()));
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_SKU_KEY), false,
            pool.getProductId().toString()));
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_QUANTITY_KEY), false, pool
            .getQuantity().toString()));
        String socketLimit = pool.getProductAttributeValue("sockets");
        if (socketLimit != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_SOCKETLIMIT_KEY), false,
                socketLimit));
        }
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_STARTDATE_KEY), false,
            iso8601DateFormat.format(pool.getStartDate())));
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_ENDDATE_KEY), false,
            iso8601DateFormat.format(pool.getEndDate())));
        // TODO : use keys
        String warningPeriod = pool.getProductAttributeValue(
            "warning_period");
        if (warningPeriod == null) {
            warningPeriod = "0";
        }
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_WARNING_PERIOD), false,
            warningPeriod));
        if (pool.getContractNumber() != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_CONTRACT_NUMBER_KEY),
                false, pool.getContractNumber()));
        }
        // Add the account number
        if (pool.getAccountNumber() != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_ACCOUNT_NUMBER_KEY),
                false, pool.getAccountNumber()));
        }
        // Add Smart Management, default to "not managed"
        String mgmt = pool.getProductAttributeValue("management_enabled");
        mgmt = (mgmt == null) ? "0" : mgmt;
        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_PROVIDES_MANAGEMENT_KEY),
            false, mgmt));

        String supportLevel = pool.getProductAttributeValue(
            "support_level");
        String supportType = pool.getProductAttributeValue("support_type");
        if (supportLevel != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_SUPPORT_LEVEL), false,
                supportLevel));
        }
        if (supportType != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_SUPPORT_TYPE), false,
                supportType));
        }
        String stackingId = pool.getProductAttributeValue("stacking_id");
        if (stackingId != null) {
            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_STACKING_ID), false,
                stackingId));
        }
View Full Code Here

        String engProdId = "1000";
        String brandedName = "Branded Eng Product";
        Product p = new Product(engProdId, "Eng Product 1000");
        p.setAttribute("brand_type", "OS");
        Set<Product> prods = new HashSet<Product>(Arrays.asList(p));
        Pool pool = TestUtil.createPool(new Product("mkt", "MKT SKU"));
        pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
        Consumer consumer = new Consumer();
        Entitlement e = new Entitlement(pool, consumer, 10);

        List<org.candlepin.json.model.Product> certProds = util.createProducts(prods, "",
            new HashMap<String, EnvironmentContent>()new Consumer(), e);
View Full Code Here

        String engProdId = "1000";
        String brandedName = "Branded Eng Product";
        Product p = new Product(engProdId, "Eng Product 1000");
        p.setAttribute("brand_type", "OS");
        Set<Product> prods = new HashSet<Product>(Arrays.asList(p));
        Pool pool = TestUtil.createPool(new Product("mkt", "MKT SKU"));
        pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
        pool.getBranding().add(new Branding(engProdId, "OS", "another brand name"));
        pool.getBranding().add(new Branding(engProdId, "OS", "number 3"));
        Set<String> possibleBrandNames = new HashSet<String>();
        for (Branding b : pool.getBranding()) {
            possibleBrandNames.add(b.getName());
        }
        Consumer consumer = new Consumer();
        Entitlement e = new Entitlement(pool, consumer, 10);
View Full Code Here

        assertFalse(output.contains("FILTERME"));
    }

    @Test
    public void filterTimestampsOffAttributes() {
        Pool p = new Pool();

        ProductPoolAttribute prodAttr = new ProductPoolAttribute("a", "1", "PRODID");
        prodAttr.setCreated(new Date());
        prodAttr.setUpdated(new Date());
        p.addProductAttribute(prodAttr);

        PoolAttribute poolAttr = new PoolAttribute("a", "1");
        poolAttr.setCreated(new Date());
        poolAttr.setUpdated(new Date());
        p.addAttribute(poolAttr);

        context.put("pool", p);

        String output = objMapper.toJsonString(context);
        // Shouldn't see timestamps:
View Full Code Here

TOP

Related Classes of org.candlepin.model.Pool

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.