Search in sources :

Example 71 with ActivationKey

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());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 72 with ActivationKey

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());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 73 with ActivationKey

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());
}
Also used : Pool(org.candlepin.model.Pool) ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 74 with ActivationKey

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());
}
Also used : ValidationResult(org.candlepin.policy.ValidationResult) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 75 with ActivationKey

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