use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method userRestrictedPoolPassesPre.
@Test
public void userRestrictedPoolPassesPre() {
Pool pool = setupUserRestrictedPool();
consumer.setUsername("bob");
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 consumerRamIsRoundedToNearestGbAndShouldNotGenerateWarning.
@Test
public void consumerRamIsRoundedToNearestGbAndShouldNotGenerateWarning() {
// Fact specified in kb - actual value of 2 GiB in kb.
Pool pool = setupArchTest("ram", "2", "memory.memtotal", "2097152");
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 testListForSufficientRAM.
@Test
public void testListForSufficientRAM() {
Product product = TestUtil.createProduct(productId, "A product for testing");
product.setAttribute(Product.Attributes.RAM, "16");
Pool pool = createPool(owner, product);
consumer.setFacts(new HashMap<>());
consumer.setFact("memory.memtotal", "16777216");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
assertTrue(result.isSuccessful());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method virtOnlyPoolGuestNoHost.
@Test
public void virtOnlyPoolGuestNoHost() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
// Another parent we'll make a virt only pool for:
Consumer otherParent = new Consumer("test parent consumer", "test user", owner, ctype);
Pool pool = setupHostRestrictedPool(otherParent);
String guestId = "virtguestuuid";
consumer.setFact("virt.is_guest", "true");
consumer.setFact("virt.uuid", guestId);
when(consumerCurator.getHost(consumer, owner.getId())).thenReturn(null);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasWarnings());
assertEquals(1, result.getErrors().size());
assertEquals("virt.guest.host.does.not.match.pool.owner", result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testListForSufficientCores.
@Test
public void testListForSufficientCores() {
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)", "1");
consumer.setFact("cpu.core(s)_per_socket", "10");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
assertTrue(result.isSuccessful());
}
Aggregations