Package org.candlepin.model

Examples of org.candlepin.model.Subscription


    }

    @Test
    public void hostedVirtLimitSubCreateAttributesTest() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        s.getProduct().setAttribute("physical_only", "true");
        List<Pool> pools = poolRules.createPools(s);

        // Should be no virt_only bonus pool:
        assertEquals(2, pools.size());
View Full Code Here


    }

    @Test
    public void standaloneVirtLimitSubCreate() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        List<Pool> pools = poolRules.createPools(s);

        // Should be no virt_only bonus pool:
        assertEquals(1, pools.size());
View Full Code Here

    }

    @Test
    public void standaloneVirtLimitSubUpdate() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
        Subscription s = createVirtLimitSub("virtLimitProduct", 10, 10);
        List<Pool> pools = poolRules.createPools(s);

        // Should be no virt_only bonus pool:
        assertEquals(1, pools.size());

        Pool physicalPool = pools.get(0);
        assertEquals(0, physicalPool.getAttributes().size());

        s.setQuantity(50L);
        List<PoolUpdate> updates = poolRules.updatePools(s, pools);
        assertEquals(1, updates.size());
        physicalPool = updates.get(0).getPool();
        assertEquals(new Long(50), physicalPool.getQuantity());
        assertEquals(0, physicalPool.getAttributes().size());
View Full Code Here

    private Subscription createVirtOnlySub(String productId, int quantity) {
        Product product = new Product(productId, productId);
        product.setAttribute("virt_only", "true");
        when(productAdapterMock.getProductById(productId)).thenReturn(product);
        Subscription s = TestUtil.createSubscription(product);
        s.setQuantity(new Long(quantity));
        return s;
    }
View Full Code Here

    }

    @Test
    public void hostedVirtOnlySubCreate() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
        Subscription s = createVirtOnlySub("virtOnlyProduct", 10);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        assertEquals("true", pools.get(0).getProductAttribute("virt_only").getValue());
        assertEquals(new Long(10), pools.get(0).getQuantity());
    }
View Full Code Here

    }

    @Test
    public void hostedVirtOnlySubCreateWithMultiplier() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
        Subscription s = createVirtOnlySub("virtOnlyProduct", 10);
        s.getProduct().setMultiplier(new Long(5));
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        assertEquals("true", pools.get(0).getProductAttribute("virt_only").getValue());
        assertEquals(new Long(50), pools.get(0).getQuantity());
    }
View Full Code Here

    }

    @Test
    public void hostedVirtOnlySubUpdate() {
        when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
        Subscription s = createVirtOnlySub("virtOnlyProduct", 10);
        List<Pool> pools = poolRules.createPools(s);
        assertEquals(1, pools.size());
        s.setQuantity(new Long(20));

        List<PoolUpdate> updates = poolRules.updatePools(s, pools);
        assertEquals(1, updates.size());
        Pool updated = updates.get(0).getPool();
        assertEquals(new Long(20), updated.getQuantity());
View Full Code Here

    @Test
    public void testRefreshPoolsWithNewSubscriptions() {
        Product prod = TestUtil.createProduct();
        productCurator.create(prod);

        Subscription sub = new Subscription(owner, prod,
            new HashSet<Product>(), 2000L, TestUtil.createDate(2010, 2, 9),
            TestUtil.createDate(3000, 2, 9), TestUtil.createDate(2010, 2, 12));
        subCurator.create(sub);

        // Trigger the refresh:
        poolManager.getRefresher().add(owner).run();
        List<Pool> pools = poolCurator.listByOwnerAndProduct(owner,
            prod.getId());
        assertEquals(1, pools.size());
        Pool newPool = pools.get(0);

        assertEquals(sub.getId(), newPool.getSubscriptionId());
        assertEquals(sub.getQuantity(), newPool.getQuantity());
        assertEquals(sub.getStartDate(), newPool.getStartDate());
        assertEquals(sub.getEndDate(), newPool.getEndDate());
    }
View Full Code Here

        Pool pool = createPoolAndSub(createOwner(), prod, 1000L,
            TestUtil.createDate(2009, 11, 30),
            TestUtil.createDate(2015, 11, 30));
        Owner owner = pool.getOwner();

        Subscription sub = new Subscription(owner, prod,
            new HashSet<Product>(), 2000L, TestUtil.createDate(2010, 2, 9),
            TestUtil.createDate(3000, 2, 9), TestUtil.createDate(2010, 2, 12));
        subCurator.create(sub);
        assertTrue(pool.getQuantity() < sub.getQuantity());
        assertTrue(pool.getStartDate() != sub.getStartDate());
        assertTrue(pool.getEndDate() != sub.getEndDate());

        pool.getSourceSubscription().setSubscriptionId(sub.getId());
        poolCurator.merge(pool);

        poolManager.getRefresher().add(owner).run();

        pool = poolCurator.find(pool.getId());
        assertEquals(sub.getId(), pool.getSubscriptionId());
        assertEquals(sub.getQuantity(), pool.getQuantity());
        assertEquals(sub.getStartDate(), pool.getStartDate());
        assertEquals(sub.getEndDate(), pool.getEndDate());
    }
View Full Code Here

    @Test
    public void testRefreshPoolsWithRemovedSubscriptions() {
        Product prod = TestUtil.createProduct();
        productCurator.create(prod);

        Subscription sub = new Subscription(owner, prod,
            new HashSet<Product>(), 2000L, TestUtil.createDate(2010, 2, 9),
            TestUtil.createDate(3000, 2, 9), TestUtil.createDate(2010, 2, 12));
        subCurator.create(sub);

        // Trigger the refresh:
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.