use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementWithDerivedProductCapabilitySuccessOnBestPools.
@Test
public void preEntitlementWithDerivedProductCapabilitySuccessOnBestPools() {
Consumer c = this.createMockConsumer(true);
HashSet<ConsumerCapability> capabilities = new HashSet<>();
capabilities.add(new ConsumerCapability(c, "derived_product"));
c.setCapabilities(capabilities);
Product prod = TestUtil.createProduct();
Product derived = TestUtil.createProduct("sub-prod-id");
Pool p = TestUtil.createPool(prod);
p.setDerivedProduct(derived);
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BEST_POOLS);
assertNotNull(results);
assertTrue("Expected no warnings or errors.", results.isSuccessful());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoInstanceCapableBindError.
@Test
public void preEntitlementNoInstanceCapableBindError() {
// 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.BIND);
assertNotNull(results);
assertEquals(0, results.getWarnings().size());
ValidationError error = results.getErrors().get(0);
assertEquals("rulefailed.instance.unsupported.by.consumer", error.getResourceKey());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoDerivedProductCapabilityProducesErrorOnBind.
@Test
public void preEntitlementNoDerivedProductCapabilityProducesErrorOnBind() {
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.BIND);
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());
}
use of org.candlepin.policy.ValidationResult 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.ValidationResult 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());
}
Aggregations