Search in sources :

Example 26 with ValidationResult

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

the class PreEntitlementRulesTest method testEmptyUname.

@Test
public void testEmptyUname() {
    Pool pool = setupArchTest("arch", "s390x,x86", "uname.machine", "");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 27 with ValidationResult

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

the class PreEntitlementRulesTest method testBindFromSameProductAllowedWithMultiEntitlementAttribute.

@Test
public void testBindFromSameProductAllowedWithMultiEntitlementAttribute() {
    Product product = TestUtil.createProduct(productId, "A product for testing");
    product.setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
    Pool pool = createPool(owner, product);
    Entitlement e = new Entitlement(pool, consumer, owner, 1);
    consumer.addEntitlement(e);
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertTrue(result.isSuccessful());
    assertFalse(result.hasErrors());
    assertFalse(result.hasErrors());
}
Also used : Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Entitlement(org.candlepin.model.Entitlement) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 28 with ValidationResult

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

the class PreEntitlementRulesTest method testListForInsufficientRAM.

@Test
public void testListForInsufficientRAM() {
    Product product = TestUtil.createProduct(productId, "A product for testing");
    product.setAttribute(Product.Attributes.RAM, "10");
    Pool pool = createPool(owner, product);
    consumer.setFacts(new HashMap<>());
    consumer.setFact("memory.memtotal", "16777216");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());
    assertTrue(result.isSuccessful());
    assertEquals("rulewarning.unsupported.ram", result.getWarnings().get(0).getResourceKey());
}
Also used : Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 29 with ValidationResult

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

the class PreEntitlementRulesTest method multipleArchesNoMatches.

@Test
public void multipleArchesNoMatches() {
    Pool pool = setupArchTest("arch", "s390x,z80,ppc64", "uname.machine", "i686");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 30 with ValidationResult

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

the class PreEntitlementRulesTest method goodArchNoUnameMachine.

@Test
public void goodArchNoUnameMachine() {
    Pool pool = setupArchTest("arch", "x86", "something.not.uname", "i686");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertTrue(result.hasWarnings());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Aggregations

ValidationResult (org.candlepin.policy.ValidationResult)116 Pool (org.candlepin.model.Pool)111 Test (org.junit.Test)105 Product (org.candlepin.model.Product)38 Consumer (org.candlepin.model.Consumer)36 ConsumerType (org.candlepin.model.ConsumerType)22 HashSet (java.util.HashSet)19 Entitlement (org.candlepin.model.Entitlement)15 ActivationKey (org.candlepin.model.activationkeys.ActivationKey)14 ValidationError (org.candlepin.policy.ValidationError)13 ArrayList (java.util.ArrayList)11 LinkedList (java.util.LinkedList)11 ConsumerCapability (org.candlepin.model.ConsumerCapability)11 Date (java.util.Date)10 HashMap (java.util.HashMap)9 Matchers.anyString (org.mockito.Matchers.anyString)9 List (java.util.List)8 EntitlementRefusedException (org.candlepin.policy.EntitlementRefusedException)8 PreUnbindHelper (org.candlepin.policy.js.entitlement.PreUnbindHelper)8 PoolQuantity (org.candlepin.model.PoolQuantity)7