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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations