use of org.candlepin.policy.js.pool.PoolRules in project candlepin by candlepin.
the class PoolManagerTest method createPoolsForExistingSubscriptionsMasterExist.
@Test
public void createPoolsForExistingSubscriptionsMasterExist() {
Owner owner = this.getOwner();
PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
List<Subscription> subscriptions = new ArrayList<>();
Product prod = TestUtil.createProduct();
Set<Product> products = new HashSet<>();
products.add(prod);
// productCache.addProducts(products);
prod.setAttribute(Product.Attributes.VIRT_LIMIT, "4");
Subscription s = TestUtil.createSubscription(owner, prod);
subscriptions.add(s);
this.mockProducts(owner, prod);
when(mockSubAdapter.getSubscriptions(any(Owner.class))).thenReturn(subscriptions);
when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
List<Pool> existingPools = new LinkedList<>();
Pool p = TestUtil.createPool(prod);
p.setSourceSubscription(new SourceSubscription(s.getId(), "master"));
existingPools.add(p);
List<Pool> newPools = pRules.createAndEnrichPools(s, existingPools);
assertEquals(newPools.size(), 1);
assertEquals(newPools.get(0).getSourceSubscription().getSubscriptionSubKey(), "derived");
}
use of org.candlepin.policy.js.pool.PoolRules in project candlepin by candlepin.
the class PoolManagerTest method derivedProvidedProductsCopiedOntoMasterPoolWhenCreatingNewPool.
@Test
public void derivedProvidedProductsCopiedOntoMasterPoolWhenCreatingNewPool() {
Product product = TestUtil.createProduct();
Product subProduct = TestUtil.createProduct();
Product subProvidedProduct = TestUtil.createProduct();
Subscription sub = TestUtil.createSubscription(owner, product);
sub.setDerivedProduct(subProduct.toDTO());
Set<ProductData> subProvided = new HashSet<>();
subProvided.add(subProvidedProduct.toDTO());
sub.setDerivedProvidedProducts(subProvided);
this.mockProducts(owner, product, subProduct, subProvidedProduct);
PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
List<Pool> pools = pRules.createAndEnrichPools(sub);
assertEquals(1, pools.size());
Pool resultPool = pools.get(0);
assertEquals(1, resultPool.getDerivedProvidedProducts().size());
}
use of org.candlepin.policy.js.pool.PoolRules in project candlepin by candlepin.
the class PoolManagerTest method subProductAttributesCopiedOntoPoolWhenCreatingNewPool.
@Test
public void subProductAttributesCopiedOntoPoolWhenCreatingNewPool() {
Product product = TestUtil.createProduct();
Product subProduct = TestUtil.createProduct();
Subscription sub = TestUtil.createSubscription(owner, product);
sub.setDerivedProduct(subProduct.toDTO());
String testAttributeKey = "multi-entitlement";
String expectedAttributeValue = "yes";
subProduct.setAttribute(testAttributeKey, expectedAttributeValue);
this.mockProducts(owner, product, subProduct);
PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
List<Pool> pools = pRules.createAndEnrichPools(sub);
assertEquals(1, pools.size());
Pool resultPool = pools.get(0);
assertNotNull(resultPool.getDerivedProduct());
assertTrue(resultPool.getDerivedProduct().hasAttribute(testAttributeKey));
assertEquals(expectedAttributeValue, resultPool.getDerivedProduct().getAttributeValue(testAttributeKey));
}
use of org.candlepin.policy.js.pool.PoolRules in project candlepin by candlepin.
the class PoolManagerTest method subProductIdCopiedOntoPoolWhenCreatingNewPool.
@Test
public void subProductIdCopiedOntoPoolWhenCreatingNewPool() {
Product product = TestUtil.createProduct();
Product subProduct = TestUtil.createProduct();
Subscription sub = TestUtil.createSubscription(owner, product);
sub.setDerivedProduct(subProduct.toDTO());
this.mockProducts(owner, product, subProduct);
PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
List<Pool> pools = pRules.createAndEnrichPools(sub);
assertEquals(1, pools.size());
Pool resultPool = pools.get(0);
assertEquals(subProduct, resultPool.getDerivedProduct());
}
use of org.candlepin.policy.js.pool.PoolRules in project candlepin by candlepin.
the class PoolManagerTest method productAttributesCopiedOntoPoolWhenCreatingNewPool.
@Test
public void productAttributesCopiedOntoPoolWhenCreatingNewPool() {
// Why is this test in pool manager? It looks like a pool rules test.
PoolRules pRules = new PoolRules(manager, mockConfig, entitlementCurator, mockOwnerProductCurator, mockProductCurator);
Product product = TestUtil.createProduct();
product.setLocked(true);
String testAttributeKey = "multi-entitlement";
String expectedAttributeValue = "yes";
product.setAttribute(testAttributeKey, expectedAttributeValue);
Subscription sub = TestUtil.createSubscription(owner, product);
this.mockProducts(owner, product);
List<Pool> pools = pRules.createAndEnrichPools(sub);
assertEquals(1, pools.size());
Pool resultPool = pools.get(0);
assertNotNull(resultPool.getProduct());
assertTrue(resultPool.getProduct().hasAttribute(testAttributeKey));
assertEquals(expectedAttributeValue, resultPool.getProduct().getAttributeValue(testAttributeKey));
}
Aggregations