use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testActivationKeyRulesUnlimitedQuantity.
@Test
public void testActivationKeyRulesUnlimitedQuantity() {
ActivationKey key = new ActivationKey();
Pool pool = genPool();
// Unlimited
pool.setQuantity(-1L);
pool.setConsumed(4L);
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 testDoesntAllowPeoplePools.
@Test
public void testDoesntAllowPeoplePools() {
ActivationKey key = new ActivationKey();
Pool pool = genPoolForType("person");
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
assertTrue(result.getWarnings().isEmpty());
assertEquals(1, result.getErrors().size());
String expected = "rulefailed.actkey.cannot.use.person.pools";
assertEquals(expected, result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testNonMultientOneTwice.
@Test
public void testNonMultientOneTwice() {
ActivationKey key = new ActivationKey();
Pool pool = genNonMultiEnt();
key.addPool(pool, 1L);
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
assertTrue(result.getWarnings().isEmpty());
assertEquals(1, result.getErrors().size());
String expected = "rulefailed.already.exists";
assertEquals(expected, result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testNullQuantityInstanceAndPhysicalOnly.
@Test
public void testNullQuantityInstanceAndPhysicalOnly() {
ActivationKey key = new ActivationKey();
key.addPool(genInstanceBased(), null);
ValidationResult result = actKeyRules.runPreActKey(key, genPhysOnlyPool(), 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 testAllowsAddingVirtQuantityInstanceBased.
/*
* Adding an invalid (physical) quantity of an instance based subscription
* should not cause a failure if there are no physical pools.
*/
@Test
public void testAllowsAddingVirtQuantityInstanceBased() {
ActivationKey key = new ActivationKey();
key.addPool(genPool(), new Long(1));
Pool pool = genInstanceBased();
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
assertTrue(result.getWarnings().isEmpty());
assertTrue(result.getErrors().isEmpty());
}
Aggregations