use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method instanceAutobindForPhysicalNoSocketFact.
@Test
public void instanceAutobindForPhysicalNoSocketFact() {
List<Pool> pools = createInstanceBasedPool();
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, bestPools.size());
PoolQuantity q = bestPools.get(0);
assertEquals(new Integer(2), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testPoolQuantityCompare.
@Test
public void testPoolQuantityCompare() {
Product prod = mockProduct(productId, "some prod", "2");
Pool pool1 = TestUtil.createPool(owner, prod, 10);
pool1.setId("1234");
PoolQuantity pq1 = new PoolQuantity(pool1, 5);
PoolQuantity pq2 = new PoolQuantity(pool1, 7);
assertEquals(-1, pq1.compareTo(pq2));
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testPoolQuantityCompareEqual.
@Test
public void testPoolQuantityCompareEqual() {
Product prod = mockProduct(productId, "some prod", "2");
Pool pool1 = TestUtil.createPool(owner, prod, 10);
pool1.setId("1234");
PoolQuantity pq1 = new PoolQuantity(pool1, 5);
PoolQuantity pq2 = new PoolQuantity(pool1, 5);
assertEquals(0, pq1.compareTo(pq2));
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method autobindForPhysicalSocketPicksBestFitBalance.
@Test
public void autobindForPhysicalSocketPicksBestFitBalance() {
List<Pool> pools = createSocketPool(3, 100, "1");
pools.addAll(createSocketPool(5, 100, "2"));
setupConsumer("8", false);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
// Should always pick the 3 socket subscription, becuase 3*3 gives 1 socket over-coverage,
// and 2*5 provides 2 extra sockets. using 1 quantity is worth .5 sockets
assertEquals(1, bestPools.size());
PoolQuantity q = bestPools.get(0);
assertEquals(new Integer(3), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testPoolQuantityCompareDiffPool.
@Test
public void testPoolQuantityCompareDiffPool() {
Product prod = mockProduct(productId, "some prod", "2");
Pool pool1 = TestUtil.createPool(owner, prod, 10);
pool1.setId("1234");
Pool pool2 = TestUtil.createPool(owner, prod, 10);
pool2.setId("4321");
PoolQuantity pq1 = new PoolQuantity(pool1, 5);
PoolQuantity pq2 = new PoolQuantity(pool2, 5);
assertTrue(pq1.compareTo(pq2) != 0);
assertEquals(pq1.compareTo(pq2), -pq2.compareTo(pq1));
}
Aggregations