use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.
the class PoolRulesTest method productNameChanged.
@Test
public void productNameChanged() {
Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
// Setup a pool with a single (different) provided product:
Pool p1 = TestUtil.clone(p);
p1.getProduct().setName("somethingelse");
List<Pool> existingPools = Arrays.asList(p1);
List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), TestUtil.stubChangedProducts(p.getProduct()));
assertEquals(1, updates.size());
PoolUpdate update = updates.get(0);
assertTrue(update.getProductsChanged());
assertFalse(update.getDatesChanged());
assertFalse(update.getQuantityChanged());
assertEquals(p.getProduct().getName(), update.getPool().getProductName());
}
use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.
the class PoolRulesTest method standaloneVirtLimitSubUpdate.
@Test
public void standaloneVirtLimitSubUpdate() {
when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
Pool p = createVirtLimitPool("virtLimitProduct", 10, 10);
when(poolManagerMock.isManaged(eq(p))).thenReturn(true);
List<Pool> pools = poolRules.createAndEnrichPools(p, new LinkedList<>());
// Should be unmapped virt_only pool:
assertEquals(2, pools.size());
Pool physicalPool = pools.get(0);
assertEquals(0, physicalPool.getAttributes().size());
p = createVirtLimitPool("virtLimitProduct", 10, 10);
p.setQuantity(50L);
List<PoolUpdate> updates = poolRules.updatePools(p, pools, p.getQuantity(), Collections.<String, Product>emptyMap());
assertEquals(2, updates.size());
physicalPool = updates.get(0).getPool();
assertEquals(new Long(50), physicalPool.getQuantity());
assertEquals(0, physicalPool.getAttributes().size());
}
use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.
the class PoolRulesTest method virtOnlyQuantityChanged.
@Test
public void virtOnlyQuantityChanged() {
Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
p.getProduct().setAttribute(Product.Attributes.VIRT_LIMIT, "5");
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(40L);
List<Pool> existingPools = Arrays.asList(p1);
List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), null);
assertEquals(1, updates.size());
PoolUpdate update = updates.get(0);
assertFalse(update.getProductsChanged());
assertFalse(update.getDatesChanged());
assertFalse(update.getProductAttributesChanged());
assertTrue(update.getQuantityChanged());
assertEquals(Long.valueOf(50), update.getPool().getQuantity());
}
use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.
the class PoolRulesTest method datesNameChanged.
@Test
public void datesNameChanged() {
Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
// Setup a pool with a single (different) provided product:
Pool p1 = TestUtil.clone(p);
p1.setEndDate(new Date());
List<Pool> existingPools = Arrays.asList(p1);
List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), Collections.<String, Product>emptyMap());
assertEquals(1, updates.size());
PoolUpdate update = updates.get(0);
assertFalse(update.getProductsChanged());
assertTrue(update.getDatesChanged());
assertFalse(update.getQuantityChanged());
assertEquals(p.getEndDate(), update.getPool().getEndDate());
}
use of org.candlepin.policy.js.pool.PoolUpdate in project candlepin by candlepin.
the class PoolRulesTest method quantityChanged.
@Test
public void quantityChanged() {
Pool p = TestUtil.createPool(owner, TestUtil.createProduct());
// Setup a pool with a single (different) provided product:
Pool p1 = TestUtil.clone(p);
p1.setQuantity(2000L);
List<Pool> existingPools = Arrays.asList(p1);
List<PoolUpdate> updates = this.poolRules.updatePools(p, existingPools, p.getQuantity(), Collections.<String, Product>emptyMap());
assertEquals(1, updates.size());
PoolUpdate update = updates.get(0);
assertFalse(update.getProductsChanged());
assertFalse(update.getDatesChanged());
assertTrue(update.getQuantityChanged());
assertEquals(p.getQuantity(), update.getPool().getQuantity());
}
Aggregations