Search in sources :

Example 26 with ActivationKey

use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.

the class ActivationKeyRulesTest method testActivationKeyRulesSufficientQuantity.

/*
     * the number of available subscriptions shouldn't matter, only
     * the total number
     */
@Test
public void testActivationKeyRulesSufficientQuantity() {
    ActivationKey key = new ActivationKey();
    Pool pool = genPool();
    pool.setQuantity(5L);
    pool.setConsumed(4L);
    // Attempting to overconsume the pool
    ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(2));
    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 27 with ActivationKey

use of org.candlepin.model.activationkeys.ActivationKey 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 28 with ActivationKey

use of org.candlepin.model.activationkeys.ActivationKey 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 29 with ActivationKey

use of org.candlepin.model.activationkeys.ActivationKey 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 30 with ActivationKey

use of org.candlepin.model.activationkeys.ActivationKey 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)

Aggregations

ActivationKey (org.candlepin.model.activationkeys.ActivationKey)76 Test (org.junit.Test)55 Pool (org.candlepin.model.Pool)38 Product (org.candlepin.model.Product)16 ActivationKeyPool (org.candlepin.model.activationkeys.ActivationKeyPool)15 ArrayList (java.util.ArrayList)14 ValidationResult (org.candlepin.policy.ValidationResult)14 Consumer (org.candlepin.model.Consumer)13 ActivationKeyCurator (org.candlepin.model.activationkeys.ActivationKeyCurator)13 PoolManager (org.candlepin.controller.PoolManager)11 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)10 Owner (org.candlepin.model.Owner)10 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 BadRequestException (org.candlepin.common.exceptions.BadRequestException)9 Date (java.util.Date)8 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)8 HashSet (java.util.HashSet)6