use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method ensureSelectBestPoolsFiltersPoolsBySLAWhenOrgHasSLASet.
@Test
public void ensureSelectBestPoolsFiltersPoolsBySLAWhenOrgHasSLASet() {
// Create Premium SLA prod
String slaPremiumProdId = "premium-sla-product";
Product slaPremiumProduct = TestUtil.createProduct(slaPremiumProdId, "Product with SLA Permium");
slaPremiumProduct.setAttribute(Product.Attributes.SUPPORT_LEVEL, "Premium");
Pool slaPremiumPool = TestUtil.createPool(owner, slaPremiumProduct);
slaPremiumPool.setId("pool-with-premium-sla");
slaPremiumPool.getProduct().setAttribute(Product.Attributes.SUPPORT_LEVEL, "Premium");
// Create Standard SLA Product
String slaStandardProdId = "standard-sla-product";
Product slaStandardProduct = TestUtil.createProduct(slaStandardProdId, "Product with SLA Standard");
slaStandardProduct.setAttribute(Product.Attributes.SUPPORT_LEVEL, "Standard");
Pool slaStandardPool = TestUtil.createPool(owner, slaStandardProduct);
slaStandardPool.setId("pool-with-standard-sla");
slaStandardPool.getProduct().setAttribute(Product.Attributes.SUPPORT_LEVEL, "Standard");
// Create a product with no SLA.
Product noSLAProduct = TestUtil.createProduct(productId, "A test product");
Pool noSLAPool = TestUtil.createPool(owner, noSLAProduct);
noSLAPool.setId("pool-1");
List<Pool> pools = new LinkedList<>();
pools.add(noSLAPool);
pools.add(slaPremiumPool);
pools.add(slaStandardPool);
// SLA filtering only occurs when consumer has SLA set.
consumer.setServiceLevel("");
owner.setDefaultServiceLevel("Premium");
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId, slaPremiumProdId, slaStandardProdId }, pools, compliance, null, new HashSet<>(), false);
assertEquals(2, bestPools.size());
assertTrue(bestPools.contains(new PoolQuantity(slaPremiumPool, 1)));
assertTrue(bestPools.contains(new PoolQuantity(noSLAPool, 1)));
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method unlimitedPoolIsPickedUp.
@Test
public void unlimitedPoolIsPickedUp() {
Product product = TestUtil.createProduct(productId, "my-prod");
product.setAttribute(Product.Attributes.SOCKETS, "2");
Pool pool = TestUtil.createPool(owner, product, -1);
pool.setId("POOL-ID");
List<Pool> pools = new LinkedList<>();
pools.add(pool);
List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { product.getId() }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, bestPools.size());
assertEquals(new Integer(1), bestPools.get(0).getQuantity());
assertEquals("POOL-ID", bestPools.get(0).getPool().getId());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method unenforcedStackedAutobindForPhysical8Socket.
// Testing an edge case, stacking ID defined, but no attributes specified to enforce:
@Test
public void unenforcedStackedAutobindForPhysical8Socket() {
List<Pool> pools = createStackedPoolEnforcingNothing();
setupConsumer("8", false);
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(1), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method instanceAutobindForVirt8Vcpu.
@Test
public void instanceAutobindForVirt8Vcpu() {
List<Pool> pools = createInstanceBasedPool();
setupConsumer("8", true);
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(1), q.getQuantity());
}
use of org.candlepin.model.PoolQuantity in project candlepin by candlepin.
the class AutobindRulesTest method testSelectBestPoolsDoesntFilterTooMuchContentForHypervisor.
public void testSelectBestPoolsDoesntFilterTooMuchContentForHypervisor() {
Pool pool = createV3OnlyPool();
List<Pool> pools = new LinkedList<>();
pools.add(pool);
// Create a hypervisor consumer which does *not* have a certificate version fact.
// This replicates the real world scenario for virt-who created hypervisors.
ConsumerType ctype = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
ctype.setId("test-ctype");
consumer = new Consumer("test consumer", "test user", owner, ctype);
when(consumerTypeCurator.find(eq(ctype.getId()))).thenReturn(ctype);
when(consumerTypeCurator.lookupByLabel(eq(ctype.getLabel()))).thenReturn(ctype);
when(consumerTypeCurator.getConsumerType(eq(consumer))).thenReturn(ctype);
List<PoolQuantity> results = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
assertEquals(1, results.size());
}
Aggregations