Package org.candlepin.model

Examples of org.candlepin.model.Subscription


        List<String> subIds = subAdapter.getSubscriptionIds(owner);
        log.debug("Found " + subIds.size() + " existing subscriptions.");

        List<String> deletedSubs = new LinkedList<String>();
        for (String subId : subIds) {
            Subscription sub = subAdapter.getSubscription(subId);

            // If this sub has been removed since getSubscriptionIds was called,
            if (sub == null) {
                deletedSubs.add(subId);
                log.warn("Couldn't load subscription, assuming it has been deleted: " + subId);
View Full Code Here


            }
            log.info("Cleaning up expired pool: " + p.getId() +
                " (" + p.getEndDate() + ")");

            if (!subAdapter.isReadOnly()) {
                Subscription sub = subAdapter.getSubscription(p.getSubscriptionId());
                // In case it was already deleted:
                if (sub != null) {
                    subAdapter.deleteSubscription(sub);
                }
            }
View Full Code Here

     * @param mergedPool
     * @return
     */
    private EntitlementCertificate generateEntitlementCertificate(
        Pool pool, Entitlement e, boolean generateUeberCert) {
        Subscription sub = null;
        if (pool.getSubscriptionId() != null) {
            sub = subAdapter.getSubscription(pool.getSubscriptionId());
        }

        Product product = null;
        /*
         * If we have a subscription for this pool, the products we need are already
         * loaded as this saves us some product adapter lookups.
         *
         * If not we'll have to look them up based on the pool's data.
         */
        if (sub != null) {
            // Need to make sure that we check for a defined sub product
            // if it is a derived pool.
            boolean derived = pool.getType() != PoolType.NORMAL;
            product = derived && sub.getDerivedProduct() != null ? sub.getDerivedProduct() :
                sub.getProduct();
        }
        else {
            // Some pools may not have a subscription, i.e. derived from stack pools.
            product = productCache.getProductById(e.getProductId());
        }
View Full Code Here

        assertEquals(sub.getCdn().getLabel(), meta.getCdnLabel());
    }

    private Subscription createSubscription(Owner daOwner, String productId,
            String poolId, String entId, String conId, long quantity) {
        Subscription sub = new Subscription();
        sub.setProduct(new Product(productId, productId));
        sub.setUpstreamPoolId(poolId);
        sub.setUpstreamEntitlementId(entId);
        sub.setUpstreamConsumerId(conId);
        sub.setQuantity(quantity);
        sub.setOwner(daOwner);
        sub.setId("" + index++);
        return sub;
    }
View Full Code Here

        return createSubscription(owner, product, new HashSet<Product>());
    }

    public static Subscription createSubscription(Owner owner, Product product,
        Set<Product> providedProducts) {
        Subscription sub = new Subscription(owner, product,
            providedProducts, 1000L, createDate(2000, 1, 1), createDate(
                2050, 1, 1), createDate(2000, 1, 1));
        return sub;
    }
View Full Code Here

    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

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testRefreshPoolsOnlyRegeneratesFloatingWhenNecessary() {
        List<Subscription> subscriptions = Util.newList();
        Product product = TestUtil.createProduct();
        Subscription sub = TestUtil.createSubscription(getOwner(), product);
        sub.setId("testing-subid");
        subscriptions.add(sub);

        // Set up pools
        List<Pool> pools = Util.newList();

        // Should be unchanged
        Pool p = TestUtil.createPool(product);
        p.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
        pools.add(p);

        // Should be regenerated because it has no subscription id
        Pool floating = TestUtil.createPool(TestUtil.createProduct());
        floating.setSourceSubscription(null);
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testRefreshPoolsOnlyRegeneratesWhenNecessary() {
        List<Subscription> subscriptions = Util.newList();
        Product product = TestUtil.createProduct();
        Subscription sub = TestUtil.createSubscription(getOwner(), product);
        sub.setId("testing-subid");
        subscriptions.add(sub);

        // Set up pools
        List<Pool> pools = Util.newList();

        // Should be unchanged
        Pool p = TestUtil.createPool(product);
        p.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
        p.setOwner(sub.getOwner());
        pools.add(p);

        mockSubsList(subscriptions);

        mockPoolsList(pools);
View Full Code Here

    @Test
    public void refreshPoolsCreatingPoolsForExistingSubscriptions() {
        List<Subscription> subscriptions = Util.newList();
        List<Pool> pools = Util.newList();
        Subscription s = TestUtil.createSubscription(getOwner(),
            TestUtil.createProduct());
        subscriptions.add(s);
        mockSubsList(subscriptions);

        mockPoolsList(pools);

        List<Pool> newPools = new LinkedList<Pool>();
        Pool p = TestUtil.createPool(s.getProduct());
        p.setSourceSubscription(new SourceSubscription(s.getId(), "master"));
        newPools.add(p);
        when(poolRulesMock.createPools(eq(s), any(List.class))).thenReturn(newPools);

        this.manager.getRefresher().add(getOwner()).run();
        verify(this.mockPoolCurator, times(1)).create(any(Pool.class));
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void refreshPoolsCleanupPoolThatLostVirtLimit() {
        List<Subscription> subscriptions = Util.newList();
        List<Pool> pools = Util.newList();
        Subscription s = TestUtil.createSubscription(getOwner(),
            TestUtil.createProduct());
        s.setId("01923");
        subscriptions.add(s);
        Pool p = TestUtil.createPool(s.getProduct());
        p.setSourceSubscription(new SourceSubscription(s.getId(), "master"));
        p.setMarkedForDelete(true);
        p.setOwner(s.getOwner());
        pools.add(p);

        mockSubsList(subscriptions);

        mockPoolsList(pools);
View Full Code Here

TOP

Related Classes of org.candlepin.model.Subscription

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.