use of org.candlepin.controller.PoolManager 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.controller.PoolManager 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.controller.PoolManager 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.controller.PoolManager in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNullQuantity.
@Test
public void testActivationKeyWithNullQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
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", null);
}
Aggregations