Search in sources :

Example 11 with ValidationResult

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

the class ActivationKeyRulesTest method testActivationKeyRulesNoPools.

@Test
public void testActivationKeyRulesNoPools() {
    ActivationKey key = new ActivationKey();
    Pool pool = genPool();
    ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
    assertTrue(result.getErrors().isEmpty());
    assertTrue(result.getWarnings().isEmpty());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 12 with ValidationResult

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

the class ActivationKeyRulesTest method testDoesAllowSameConsumerTypePools.

@Test
public void testDoesAllowSameConsumerTypePools() {
    ActivationKey key = new ActivationKey();
    key.addPool(genPoolForType("system"), 1L);
    Pool pool = genPoolForType("system");
    ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
    assertTrue(result.getWarnings().isEmpty());
    assertTrue(result.getErrors().isEmpty());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 13 with ValidationResult

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

the class ActivationKeyRulesTest method testNonMultientMultipleQuantity.

@Test
public void testNonMultientMultipleQuantity() {
    ActivationKey key = new ActivationKey();
    Pool pool = genNonMultiEnt();
    ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(2));
    assertTrue(result.getWarnings().isEmpty());
    assertEquals(1, result.getErrors().size());
    String expected = "rulefailed.invalid.nonmultient.quantity";
    assertEquals(expected, result.getErrors().get(0).getResourceKey());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 14 with ValidationResult

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

the class ActivationKeyRulesTest method testNonMultientOne.

@Test
public void testNonMultientOne() {
    ActivationKey key = new ActivationKey();
    Pool pool = genNonMultiEnt();
    ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
    assertTrue(result.getWarnings().isEmpty());
    assertTrue(result.getErrors().isEmpty());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 15 with ValidationResult

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

the class ManifestEntitlementRulesTest method preEntitlementSuccessInstanceCapable.

@Test
public void preEntitlementSuccessInstanceCapable() {
    // Test with sockets to make sure that they are skipped.
    Consumer c = this.createMockConsumer(true);
    Set<ConsumerCapability> caps = new HashSet<>();
    ConsumerCapability cc = new ConsumerCapability(c, "instance_multiplier");
    caps.add(cc);
    c.setCapabilities(caps);
    Product prod = TestUtil.createProduct();
    prod.setAttribute(Product.Attributes.INSTANCE_MULTIPLIER, "2");
    Pool p = TestUtil.createPool(prod);
    ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BEST_POOLS);
    assertNotNull(results);
    assertEquals(0, results.getErrors().size());
    assertEquals(0, results.getWarnings().size());
}
Also used : Consumer(org.candlepin.model.Consumer) Product(org.candlepin.model.Product) ConsumerCapability(org.candlepin.model.ConsumerCapability) Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) HashSet(java.util.HashSet) 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