use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNegPoolQuantity.
@Test(expected = BadRequestException.class)
public void testActivationKeyWithNegPoolQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.setQuantity(10L);
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", -3L);
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNonPersonConsumerType.
@Test
public void testActivationKeyWithNonPersonConsumerType() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.REQUIRES_CONSUMER_TYPE, "candlepin");
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
assertNotNull(akr.addPoolToKey("testKey", "testPool", 1L));
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithUnlimitedPool.
@Test
public void testActivationKeyWithUnlimitedPool() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
p.setQuantity(-1L);
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", 15L);
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testUpdateTooLongRelease.
@Test(expected = BadRequestException.class)
public void testUpdateTooLongRelease() {
ActivationKey key = new ActivationKey();
OwnerDTO ownerDto = new OwnerDTO();
key.setOwner(owner);
key.setName("dd");
key.setServiceLevel("level1");
key.setReleaseVer(new Release("release1"));
activationKeyCurator.create(key);
ActivationKeyDTO update = new ActivationKeyDTO();
update.setOwner(ownerDto);
update.setName("dd");
update.setServiceLevel("level1");
update.setReleaseVersion(TestUtil.getStringOfSize(256));
activationKeyResource.updateActivationKey(key.getId(), update);
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testAddingRemovingPools.
@Test
public void testAddingRemovingPools() {
ActivationKey key = new ActivationKey();
Product product = this.createProduct(owner);
Pool pool = createPool(owner, product, 10L, new Date(), new Date());
key.setOwner(owner);
key.setName("dd");
key = activationKeyCurator.create(key);
assertNotNull(key.getId());
activationKeyResource.addPoolToKey(key.getId(), pool.getId(), 1L);
assertTrue(key.getPools().size() == 1);
activationKeyResource.removePoolFromKey(key.getId(), pool.getId());
assertTrue(key.getPools().size() == 0);
}
Aggregations