use of org.candlepin.policy.ValidationError in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementShouldNotAllowConsumptionFromRequiresHostPools.
@Test
public void preEntitlementShouldNotAllowConsumptionFromRequiresHostPools() {
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.BIND);
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.ValidationError in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoCoreCapableBindError.
@Test
public void preEntitlementNoCoreCapableBindError() {
// Test with sockets to make sure that they are skipped.
Consumer c = this.createMockConsumer(true);
c.setFact("cpu.core(s)_per_socket", "2");
Set<ConsumerCapability> caps = new HashSet<>();
c.setCapabilities(caps);
Product prod = TestUtil.createProduct();
prod.setAttribute(Product.Attributes.CORES, "2");
Pool p = TestUtil.createPool(prod);
p.setId("poolId");
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BIND);
assertNotNull(results);
assertEquals(0, results.getWarnings().size());
ValidationError error = results.getErrors().get(0);
assertEquals("rulefailed.cores.unsupported.by.consumer", error.getResourceKey());
}
use of org.candlepin.policy.ValidationError in project candlepin by candlepin.
the class EntitlerTest method fakeOutResult.
private ValidationResult fakeOutResult(String msg) {
ValidationResult result = new ValidationResult();
ValidationError err = new ValidationError(msg);
result.addError(err);
return result;
}
use of org.candlepin.policy.ValidationError in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementShouldNotAllowOverConsumptionOfEntitlements.
@Test
public void preEntitlementShouldNotAllowOverConsumptionOfEntitlements() {
Consumer c = this.createMockConsumer(true);
Product prod = TestUtil.createProduct();
Pool p = TestUtil.createPool(prod);
p.setQuantity(5L);
ValidationResult results = enforcer.preEntitlement(c, p, 10);
assertNotNull(results);
assertEquals(1, results.getErrors().size());
ValidationError error = results.getErrors().get(0);
assertEquals("rulefailed.no.entitlements.available", error.getResourceKey());
}
use of org.candlepin.policy.ValidationError in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoDerivedProductCapabilityProducesErrorOnBestPools.
@Test
public void preEntitlementNoDerivedProductCapabilityProducesErrorOnBestPools() {
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.BEST_POOLS);
assertNotNull(results);
assertEquals(1, results.getErrors().size());
assertTrue(results.getWarnings().isEmpty());
ValidationError error = results.getErrors().get(0);
assertEquals("rulefailed.derivedproduct.unsupported.by.consumer", error.getResourceKey());
}
Aggregations