use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testListForInsufficientSockets.
@Test
public void testListForInsufficientSockets() {
Product product = TestUtil.createProduct(productId, "A product for testing");
product.setAttribute(Product.Attributes.SOCKETS, "2");
Pool pool = createPool(owner, product);
consumer.setFacts(new HashMap<>());
consumer.setFact("cpu.cpu_socket(s)", "4");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertTrue(result.hasWarnings());
assertTrue(result.isSuccessful());
assertEquals("rulewarning.unsupported.number.of.sockets", result.getWarnings().get(0).getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method bindWithQuantityNoMultiEntitle.
@Test
public void bindWithQuantityNoMultiEntitle() {
Product product = TestUtil.createProduct(productId, "A product for testing");
Pool pool = createPool(owner, product);
pool.setId("TaylorSwift");
pool.setQuantity(new Long(100));
ValidationResult result = enforcer.preEntitlement(consumer, pool, 10);
assertFalse(result.isSuccessful());
assertTrue(result.hasErrors());
assertEquals(1, result.getErrors().size());
assertTrue(result.getErrors().get(0).getResourceKey().contains("multi-entitlement"));
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method bindFromExhaustedPoolShouldFail.
@Test
public void bindFromExhaustedPoolShouldFail() {
Product product = TestUtil.createProduct(productId, "A product for testing");
Pool pool = TestUtil.createPool(owner, product, 0);
pool.setId("fakeid" + TestUtil.randomInt());
Entitlement e = new Entitlement(pool, consumer, owner, 1);
consumer.addEntitlement(e);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertTrue(result.hasErrors());
assertFalse(result.isSuccessful());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testDuplicateArchesNoMatches.
@Test
public void testDuplicateArchesNoMatches() {
Pool pool = setupArchTest("arch", "x86_64,x86_64", "uname.machine", "z80");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertTrue(result.hasWarnings());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method systemForHypervisorGeneratesError.
@Test
public void systemForHypervisorGeneratesError() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Pool pool = setupProductWithConsumerTypeAttribute(ConsumerTypeEnum.HYPERVISOR);
consumer.setType(ctype);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertTrue(result.hasErrors());
assertFalse(result.hasWarnings());
}
Aggregations