use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoInstanceCapableListWarn.
@Test
public void preEntitlementNoInstanceCapableListWarn() {
// Test with sockets to make sure that they are skipped.
Consumer c = this.createMockConsumer(true);
Set<ConsumerCapability> caps = new HashSet<>();
c.setCapabilities(caps);
Product prod = TestUtil.createProduct();
prod.setAttribute(Product.Attributes.INSTANCE_MULTIPLIER, "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.instance.unsupported.by.consumer", warning.getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoDerivedProductCapabilityProducesWarningOnList.
@Test
public void preEntitlementNoDerivedProductCapabilityProducesWarningOnList() {
Consumer c = this.createMockConsumer(true);
c.setCapabilities(new HashSet<>());
Product prod = TestUtil.createProduct();
Product derived = TestUtil.createProduct("sub-prod-id");
Pool p = TestUtil.createPool(prod);
p.setDerivedProduct(derived);
p.setId("poolId");
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.LIST_POOLS);
assertNotNull(results);
assertEquals(1, results.getWarnings().size());
assertTrue(results.getErrors().isEmpty());
ValidationWarning warning = results.getWarnings().get(0);
assertEquals("rulewarning.derivedproduct.unsupported.by.consumer", warning.getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementShouldNotAllowListOfRequiresHostPools.
@Test
public void preEntitlementShouldNotAllowListOfRequiresHostPools() {
Consumer c = this.createMockConsumer(true);
Product prod = TestUtil.createProduct();
Pool p = TestUtil.createPool(prod);
p.setAttribute(Product.Attributes.VIRT_ONLY, "true");
p.setAttribute(Pool.Attributes.REQUIRES_HOST, "true");
p.setId("poolId");
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.LIST_POOLS);
assertNotNull(results);
assertEquals(1, results.getErrors().size());
ValidationError error = results.getErrors().get(0);
assertEquals("pool.not.available.to.manifest.consumers", error.getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method unmappedGuestFuturePoolDate.
@Test
public void unmappedGuestFuturePoolDate() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Date fourHoursFromNow = new Date(new Date().getTime() + 4L * 60L * 60L * 1000L);
Pool pool = setupUnmappedGuestPool();
pool.setStartDate(fourHoursFromNow);
Consumer consumer = new Consumer("test newborn consumer", "test user", owner, ctype);
consumer.setFact("virt.is_guest", "true");
consumer.setCreated(new Date());
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1, CallerType.BIND);
assertTrue(result.hasErrors());
assertEquals(1, result.getErrors().size());
assertEquals("virt.guest.cannot.bind.future.unmapped.guest.pool", result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method virtOnlyNonHostReqPool.
@Test
public void virtOnlyNonHostReqPool() {
Pool pool = setupVirtOnlyPool();
consumer.setFact("virt.is_guest", "true");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
Aggregations