Search in sources :

Example 36 with PoolUpdate

use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.

the class PoolRulesStackDerivedTest method virtLimitFromLastVirtLimitEntWhenFirstIsRemoved.

@Test
public void virtLimitFromLastVirtLimitEntWhenFirstIsRemoved() {
    stackedEnts.clear();
    stackedEnts.add(createEntFromPool(pool1));
    stackedEnts.add(createEntFromPool(pool2));
    PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertEquals((Long) 2L, stackDerivedPool.getQuantity());
    stackedEnts.remove(0);
    update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertTrue(update.changed());
    assertTrue(update.getQuantityChanged());
    assertEquals(new Long("-1"), stackDerivedPool.getQuantity());
}
Also used : PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Example 37 with PoolUpdate

use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.

the class PoolRulesStackDerivedTest method mergedProvidedProducts.

@Test
public void mergedProvidedProducts() {
    stackedEnts.add(createEntFromPool(pool1));
    stackedEnts.add(createEntFromPool(pool3));
    PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertTrue(update.getProductsChanged());
    assertEquals(3, stackDerivedPool.getProvidedProducts().size());
    assertTrue(stackDerivedPool.getProvidedProducts().contains(provided1));
    assertTrue(stackDerivedPool.getProvidedProducts().contains(provided2));
    assertTrue(stackDerivedPool.getProvidedProducts().contains(provided3));
}
Also used : PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Example 38 with PoolUpdate

use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.

the class PoolRulesStackDerivedTest method removeEarliestStartingEntitlement.

@Test
public void removeEarliestStartingEntitlement() {
    stackedEnts.add(createEntFromPool(pool1));
    stackedEnts.add(createEntFromPool(pool3));
    poolRules.updatePoolFromStack(stackDerivedPool, null);
    // Should change a variety of settings on the pool.
    stackedEnts.remove(1);
    PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertTrue(update.changed());
    assertTrue(update.getDatesChanged());
    assertEquals(pool2.getStartDate(), stackDerivedPool.getStartDate());
    assertEquals(pool3.getEndDate(), stackDerivedPool.getEndDate());
}
Also used : PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Aggregations

PoolUpdate (org.candlepin.policy.js.pool.PoolUpdate)38 Test (org.junit.Test)35 Pool (org.candlepin.model.Pool)28 LinkedList (java.util.LinkedList)10 Product (org.candlepin.model.Product)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 EventBuilder (org.candlepin.audit.EventBuilder)4 Entitlement (org.candlepin.model.Entitlement)4 Subscription (org.candlepin.model.dto.Subscription)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)2 Branding (org.candlepin.model.Branding)2 Transactional (com.google.inject.persist.Transactional)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Event (org.candlepin.audit.Event)1 CandlepinQuery (org.candlepin.model.CandlepinQuery)1 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)1