Search in sources :

Example 36 with ValidationResult

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

the class PreEntitlementRulesTest method fewerThanMaximumNumberOfSocketsShouldNotGenerateWarning.

@Test
public void fewerThanMaximumNumberOfSocketsShouldNotGenerateWarning() {
    Pool pool = setupArchTest("sockets", "128", "cpu.cpu_socket(s)", "2");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertFalse(result.hasWarnings());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 37 with ValidationResult

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

the class PreEntitlementRulesTest method devPoolConsumerDoesNotMatch.

@Test
public void devPoolConsumerDoesNotMatch() {
    // Another consumer we'll make a dev pool for:
    ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
    Consumer otherConsumer = new Consumer("test consumer", "test user", owner, ctype);
    Pool pool = setupDevConsumerRestrictedPool(otherConsumer);
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasWarnings());
    assertEquals(1, result.getErrors().size());
    assertEquals("consumer.does.not.match.pool.consumer.requirement", result.getErrors().get(0).getResourceKey());
}
Also used : Consumer(org.candlepin.model.Consumer) Pool(org.candlepin.model.Pool) ConsumerType(org.candlepin.model.ConsumerType) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 38 with ValidationResult

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

the class PreEntitlementRulesTest method matchingNumberOfSocketsShouldNotGenerateWarning.

@Test
public void matchingNumberOfSocketsShouldNotGenerateWarning() {
    Pool pool = setupArchTest("sockets", "2", "cpu.cpu_socket(s)", "2");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertFalse(result.hasWarnings());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 39 with ValidationResult

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

the class PreEntitlementRulesTest method physOnlyVirtualConsumer.

@Test
public void physOnlyVirtualConsumer() {
    Pool pool = setupPhysOnlyPool();
    consumer.setFact("virt.is_guest", "true");
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertTrue(result.hasWarnings());
    assertEquals(1, result.getWarnings().size());
    assertEquals("rulewarning.physical.only", result.getWarnings().get(0).getResourceKey());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) Test(org.junit.Test)

Example 40 with ValidationResult

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

the class PreEntitlementRulesTest method architectureALLShouldNotGenerateWarnings.

@Test
public void architectureALLShouldNotGenerateWarnings() {
    Pool pool = setupArchTest("arch", "ALL", "arch", "i686");
    pool.setId("fakeid" + TestUtil.randomInt());
    ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
    assertFalse(result.hasErrors());
    assertFalse(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