Search in sources :

Example 11 with ActivationKey

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

the class ActivationKeyContentOverrideCuratorTest method setUp.

@Before
public void setUp() {
    owner = new Owner("test-owner", "Test Owner");
    owner = ownerCurator.create(owner);
    ct = new ConsumerType(ConsumerTypeEnum.SYSTEM);
    ct = consumerTypeCurator.create(ct);
    key = new ActivationKey("a key", owner);
    activationKeyCurator.create(key);
}
Also used : ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Before(org.junit.Before)

Example 12 with ActivationKey

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

the class ActivationKeyContentOverrideCuratorTest method testRemoveByConsumer.

@Test
public void testRemoveByConsumer() {
    ActivationKey key2 = new ActivationKey("other key", owner);
    key2 = activationKeyCurator.create(key2);
    activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key2, "test-repo", "gpgcheck", "1"));
    activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key, "test-repo", "gpgcheck", "1"));
    activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key, "another-test-repo", "gpgcheck", "0"));
    activationKeyContentOverrideCurator.removeByParent(key);
    assertTrue(activationKeyContentOverrideCurator.getList(key).isEmpty());
    assertEquals(1, activationKeyContentOverrideCurator.getList(key2).size());
}
Also used : ActivationKey(org.candlepin.model.activationkeys.ActivationKey) ActivationKeyContentOverride(org.candlepin.model.activationkeys.ActivationKeyContentOverride) Test(org.junit.Test)

Example 13 with ActivationKey

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

the class OwnerProductCuratorTest method testRemoveOwnerProductReferences.

@Test
public void testRemoveOwnerProductReferences() {
    Owner owner = this.createOwner();
    Product original = this.createProduct();
    this.createOwnerProductMapping(owner, original);
    ActivationKey key = TestUtil.createActivationKey(owner, null);
    key.setProducts(Util.asSet(original));
    this.activationKeyCurator.create(key);
    assertTrue(this.isProductMappedToOwner(original, owner));
    this.ownerProductCurator.removeOwnerProductReferences(owner, Arrays.asList(original.getUuid()));
    assertFalse(this.isProductMappedToOwner(original, owner));
    this.activationKeyCurator.refresh(key);
    Collection<Product> products = key.getProducts();
    assertEquals(0, products.size());
}
Also used : ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 14 with ActivationKey

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

the class ActivationKeyTest method testPoolRelationship.

@Test
public void testPoolRelationship() {
    ActivationKey key = createActivationKey(owner);
    Product prod = TestUtil.createProduct();
    productCurator.create(prod);
    Pool pool = createPool(owner, prod, 12L, new Date(), new Date(System.currentTimeMillis() + (365 * 24 * 60 * 60 * 1000)));
    key.addPool(pool, 5L);
    activationKeyCurator.create(key);
    activationKeyCurator.refresh(key);
    assertNotNull(poolCurator.getActivationKeysForPool(pool));
    assertNotNull(key.getPools());
    assertTrue("The count of pools should be 1", key.getPools().size() == 1);
    assertEquals(new Long(5), key.getPools().iterator().next().getQuantity());
}
Also used : ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Date(java.util.Date) Test(org.junit.Test)

Example 15 with ActivationKey

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

the class ActivationKeyTest method testNullPoolRelationship.

@Test
public void testNullPoolRelationship() {
    ActivationKey key = createActivationKey(owner);
    Product prod = TestUtil.createProduct();
    productCurator.create(prod);
    Pool pool = createPool(owner, prod, 12L, new Date(), new Date(System.currentTimeMillis() + (365 * 24 * 60 * 60 * 1000)));
    key.addPool(pool, null);
    activationKeyCurator.create(key);
    activationKeyCurator.refresh(key);
    assertNotNull(poolCurator.getActivationKeysForPool(pool));
    assertNotNull(key.getPools());
    assertTrue("The count of pools should be 1", key.getPools().size() == 1);
    assertEquals(null, key.getPools().iterator().next().getQuantity());
}
Also used : ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Date(java.util.Date) 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