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