Search in sources :

Example 31 with PoolUpdate

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

the class PoolRulesTest method productNameChangedDevPool.

@Test
public void productNameChangedDevPool() {
    Pool p = TestUtil.createPool(TestUtil.createProduct());
    p.setSourceSubscription(null);
    p.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
    List<Pool> floatingPools = new ArrayList<>();
    floatingPools.add(p);
    Product changed = p.getProduct();
    changed.setName("somethingelse");
    List<PoolUpdate> updates = this.poolRules.updatePools(floatingPools, TestUtil.stubChangedProducts(changed));
    assertEquals(0, updates.size());
}
Also used : ArrayList(java.util.ArrayList) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Example 32 with PoolUpdate

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

the class PoolRulesTest method brandingDidntChange.

@Test
public void brandingDidntChange() {
    Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
    // Add some branding to the subscription and do an update:
    Branding b1 = new Branding("8000", "OS", "Awesome OS Branded");
    Branding b2 = new Branding("8001", "OS", "Awesome OS Branded 2");
    p.getBranding().add(b1);
    p.getBranding().add(b2);
    // Copy the pool with the branding to begin with:
    Pool p1 = TestUtil.clone(p);
    List<Pool> existingPools = Arrays.asList(p1);
    List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), Collections.<String, Product>emptyMap());
    assertEquals(0, updates.size());
}
Also used : Pool(org.candlepin.model.Pool) Branding(org.candlepin.model.Branding) PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Example 33 with PoolUpdate

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

the class PoolRulesTest method dontUpdateVirtOnlyNoVirtLimit.

@Test
public void dontUpdateVirtOnlyNoVirtLimit() {
    when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
    Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
    p.setQuantity(10L);
    // Setup a pool with a single (different) provided product:
    Pool p1 = TestUtil.clone(p);
    p1.setAttribute(Product.Attributes.VIRT_ONLY, "true");
    p1.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
    p1.setQuantity(10L);
    List<Pool> existingPools = new LinkedList<>();
    existingPools.add(p1);
    List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), Collections.<String, Product>emptyMap());
    assertEquals(0, updates.size());
}
Also used : Pool(org.candlepin.model.Pool) PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 34 with PoolUpdate

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

the class PoolRulesStackDerivedTest method virtLimitNotChangedWhenLastVirtEntIsRemovedFromStack.

@Test
public void virtLimitNotChangedWhenLastVirtEntIsRemovedFromStack() {
    // Remove virt_limit from pool1 so that it is not considered
    // as virt limiting.
    Product product = pool1.getProduct();
    product.clearAttributes();
    product.setAttribute(Product.Attributes.STACKING_ID, STACK);
    product.setAttribute("testattr2", "2");
    stackedEnts.clear();
    stackedEnts.add(createEntFromPool(pool1));
    stackedEnts.add(createEntFromPool(pool2));
    PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertEquals(new Long("-1"), stackDerivedPool.getQuantity());
    stackedEnts.remove(0);
    update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertTrue(update.changed());
    assertTrue(update.getDatesChanged());
    assertFalse(update.getQuantityChanged());
    assertEquals(new Long("-1"), stackDerivedPool.getQuantity());
}
Also used : Product(org.candlepin.model.Product) PoolUpdate(org.candlepin.policy.js.pool.PoolUpdate) Test(org.junit.Test)

Example 35 with PoolUpdate

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

the class PoolRulesStackDerivedTest method virtLimitFromFirstVirtLimitEnt.

@Test
public void virtLimitFromFirstVirtLimitEnt() {
    stackedEnts.clear();
    stackedEnts.add(createEntFromPool(pool1));
    stackedEnts.add(createEntFromPool(pool3));
    PoolUpdate update = poolRules.updatePoolFromStack(stackDerivedPool, null);
    assertTrue(update.changed());
    assertTrue(update.getQuantityChanged());
    assertEquals((Long) 2L, stackDerivedPool.getQuantity());
}
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