use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoRamCapableListWarn.
@Test
public void preEntitlementNoRamCapableListWarn() {
// Test with sockets to make sure that they are skipped.
Consumer c = this.createMockConsumer(true);
c.setFact("memory.memtotal", "2000000");
Set<ConsumerCapability> caps = new HashSet<>();
c.setCapabilities(caps);
Product prod = TestUtil.createProduct();
prod.setAttribute(Product.Attributes.RAM, "2");
Pool p = TestUtil.createPool(prod);
p.setId("poolId");
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.LIST_POOLS);
assertNotNull(results);
assertEquals(0, results.getErrors().size());
ValidationWarning warning = results.getWarnings().get(0);
assertEquals("rulewarning.ram.unsupported.by.consumer", warning.getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testBindForSameProductNotAllowed.
@Test
public void testBindForSameProductNotAllowed() {
Product product = TestUtil.createProduct(productId, "A product for testing");
Pool pool = createPool(owner, product);
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 exceedingNumberOfSocketsShouldGenerateWarning.
@Test
public void exceedingNumberOfSocketsShouldGenerateWarning() {
Pool pool = setupArchTest("sockets", "2", "cpu.cpu_socket(s)", "4");
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 virtOnlyPoolGuestHostMatches.
@Test
public void virtOnlyPoolGuestHostMatches() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Consumer parent = new Consumer("test parent consumer", "test user", owner, ctype);
Pool pool = setupHostRestrictedPool(parent);
String guestId = "virtguestuuid";
consumer.setFact("virt.is_guest", "true");
consumer.setFact("virt.uuid", guestId);
when(consumerCurator.getHost(consumer, owner.getId())).thenReturn(parent);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testListForInsufficientCores.
@Test
public void testListForInsufficientCores() {
Product product = TestUtil.createProduct(productId, "A product for testing");
product.setAttribute(Product.Attributes.CORES, "10");
Pool pool = createPool(owner, product);
consumer.setFacts(new HashMap<>());
consumer.setFact("cpu.cpu_socket(s)", "2");
consumer.setFact("cpu.core(s)_per_socket", "10");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertTrue(result.hasWarnings());
assertTrue(result.isSuccessful());
assertEquals("rulewarning.unsupported.number.of.cores", result.getWarnings().get(0).getResourceKey());
}
Aggregations