Search in sources :

Example 1 with ValidationWarning

use of org.candlepin.policy.ValidationWarning 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());
}
Also used : Consumer(org.candlepin.model.Consumer) Product(org.candlepin.model.Product) ConsumerCapability(org.candlepin.model.ConsumerCapability) Pool(org.candlepin.model.Pool) ValidationWarning(org.candlepin.policy.ValidationWarning) ValidationResult(org.candlepin.policy.ValidationResult) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ValidationWarning

use of org.candlepin.policy.ValidationWarning 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());
}
Also used : Consumer(org.candlepin.model.Consumer) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) ValidationWarning(org.candlepin.policy.ValidationWarning) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 3 with ValidationWarning

use of org.candlepin.policy.ValidationWarning 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());
}
Also used : Consumer(org.candlepin.model.Consumer) Product(org.candlepin.model.Product) ConsumerCapability(org.candlepin.model.ConsumerCapability) Pool(org.candlepin.model.Pool) ValidationWarning(org.candlepin.policy.ValidationWarning) ValidationResult(org.candlepin.policy.ValidationResult) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ValidationWarning

use of org.candlepin.policy.ValidationWarning in project candlepin by candlepin.

the class ManifestEntitlementRulesTest method preEntitlementNoCoreCapableListWarn.

@Test
public void preEntitlementNoCoreCapableListWarn() {
    // 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.LIST_POOLS);
    assertNotNull(results);
    assertEquals(0, results.getErrors().size());
    ValidationWarning warning = results.getWarnings().get(0);
    assertEquals("rulewarning.cores.unsupported.by.consumer", warning.getResourceKey());
}
Also used : Consumer(org.candlepin.model.Consumer) Product(org.candlepin.model.Product) ConsumerCapability(org.candlepin.model.ConsumerCapability) Pool(org.candlepin.model.Pool) ValidationWarning(org.candlepin.policy.ValidationWarning) ValidationResult(org.candlepin.policy.ValidationResult) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Consumer (org.candlepin.model.Consumer)4 Pool (org.candlepin.model.Pool)4 Product (org.candlepin.model.Product)4 ValidationResult (org.candlepin.policy.ValidationResult)4 ValidationWarning (org.candlepin.policy.ValidationWarning)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 ConsumerCapability (org.candlepin.model.ConsumerCapability)3