Search in sources :

Example 6 with PoolManager

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);
}
Also used : ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) ActivationKeyCurator(org.candlepin.model.activationkeys.ActivationKeyCurator) ActivationKeyPool(org.candlepin.model.activationkeys.ActivationKeyPool) Pool(org.candlepin.model.Pool) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) PoolManager(org.candlepin.controller.PoolManager) Test(org.junit.Test)

Example 7 with PoolManager

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));
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Pool(org.candlepin.model.Pool) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) Entitlement(org.candlepin.model.Entitlement) PoolManager(org.candlepin.controller.PoolManager) Test(org.junit.Test)

Example 8 with PoolManager

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) ContentTranslator(org.candlepin.dto.api.v1.ContentTranslator) SimpleModelTranslator(org.candlepin.dto.SimpleModelTranslator) EnvironmentContentCurator(org.candlepin.model.EnvironmentContentCurator) ContentCurator(org.candlepin.model.ContentCurator) ProductCurator(org.candlepin.model.ProductCurator) DefaultUniqueIdGenerator(org.candlepin.service.impl.DefaultUniqueIdGenerator) EnvironmentContentCurator(org.candlepin.model.EnvironmentContentCurator) PoolManager(org.candlepin.controller.PoolManager) Before(org.junit.Before)

Example 9 with PoolManager

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);
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) HashMap(java.util.HashMap) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Entitlement(org.candlepin.model.Entitlement) PoolManager(org.candlepin.controller.PoolManager) Test(org.junit.Test)

Example 10 with PoolManager

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);
}
Also used : ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) ActivationKeyCurator(org.candlepin.model.activationkeys.ActivationKeyCurator) ActivationKeyPool(org.candlepin.model.activationkeys.ActivationKeyPool) Pool(org.candlepin.model.Pool) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) PoolManager(org.candlepin.controller.PoolManager) Test(org.junit.Test)

Aggregations

PoolManager (org.candlepin.controller.PoolManager)14 Pool (org.candlepin.model.Pool)13 Test (org.junit.Test)13 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)10 ActivationKey (org.candlepin.model.activationkeys.ActivationKey)10 ActivationKeyCurator (org.candlepin.model.activationkeys.ActivationKeyCurator)10 ActivationKeyPool (org.candlepin.model.activationkeys.ActivationKeyPool)10 HashMap (java.util.HashMap)3 Entitlement (org.candlepin.model.Entitlement)3 Owner (org.candlepin.model.Owner)2 OwnerCurator (org.candlepin.model.OwnerCurator)2 PoolQuantity (org.candlepin.model.PoolQuantity)2 Product (org.candlepin.model.Product)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Refresher (org.candlepin.controller.Refresher)1