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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations