use of org.candlepin.controller.PoolManager in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithLargePoolQuantity.
@Test
public void testActivationKeyWithLargePoolQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
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", 15L);
}
use of org.candlepin.controller.PoolManager in project candlepin by candlepin.
the class HostedVirtLimitEntitlementRulesTest method hostedParentConsumerPostCreatesNoPool.
@Test
public void hostedParentConsumerPostCreatesNoPool() {
Pool pool = setupVirtLimitPool();
List<Pool> pools = new ArrayList<>();
pools.add(pool);
Map<String, Entitlement> entitlements = new HashMap<>();
entitlements.put(pool.getId(), new Entitlement(pool, consumer, owner, 1));
Map<String, PoolQuantity> poolQuantityMap = new HashMap<>();
poolQuantityMap.put(pool.getId(), new PoolQuantity(pool, 1));
PoolManager poolManager = mock(PoolManager.class);
when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
enforcer.postEntitlement(poolManager, consumer, owner, entitlements, null, false, poolQuantityMap);
verify(poolManager, never()).createPools(any(List.class));
}
use of org.candlepin.controller.PoolManager in project candlepin by candlepin.
the class ContentResourceTest method init.
@Before
public void init() {
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
cc = mock(ContentCurator.class);
envContentCurator = mock(EnvironmentContentCurator.class);
poolManager = mock(PoolManager.class);
oc = mock(OwnerCurator.class);
productCurator = mock(ProductCurator.class);
this.modelTranslator = new SimpleModelTranslator();
this.modelTranslator.registerTranslator(new ContentTranslator(), Content.class, ContentDTO.class);
cr = new ContentResource(cc, i18n, new DefaultUniqueIdGenerator(), envContentCurator, poolManager, productCurator, oc, this.modelTranslator);
}
use of org.candlepin.controller.PoolManager in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method postEntitlement.
@Test
public void postEntitlement() {
Consumer c = this.createMockConsumer(true);
Owner o = mock(Owner.class);
PoolManager pm = mock(PoolManager.class);
Entitlement e = mock(Entitlement.class);
Pool pool = mock(Pool.class);
Product product = mock(Product.class);
when(e.getPool()).thenReturn(pool);
when(e.getConsumer()).thenReturn(c);
when(pool.getProductId()).thenReturn("testProd");
when(product.getAttributes()).thenReturn(new HashMap<>());
when(pool.getAttributes()).thenReturn(new HashMap<>());
Map<String, Entitlement> entitlements = new HashMap<>();
entitlements.put("pool", e);
Map<String, PoolQuantity> poolQuantityMap = new HashMap<>();
poolQuantityMap.put("pool", new PoolQuantity(pool, 1));
enforcer.postEntitlement(pm, c, o, entitlements, null, false, poolQuantityMap);
}
use of org.candlepin.controller.PoolManager in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithDiffHostReqPools.
@Test
public void testActivationKeyWithDiffHostReqPools() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
PoolManager poolManager = mock(PoolManager.class);
Pool p1 = genPool();
p1.setAttribute(Pool.Attributes.REQUIRES_HOST, "host1");
Pool p2 = genPool();
p2.setAttribute(Pool.Attributes.REQUIRES_HOST, "host2");
ak.addPool(p2, 1L);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool1"))).thenReturn(p1);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool1", 1L);
}
Aggregations