use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.
the class DefaultEntitlementCertServiceAdapterTest method setupEntitlements.
private void setupEntitlements(String consumerArch, String certVersion) {
consumer.setFact("system.certificate_version", certVersion);
consumer.setFact("uname.machine", consumerArch);
ProductData pdata = subscription.getProduct();
pdata.setAttribute(Product.Attributes.WARNING_PERIOD, "20");
pdata.setAttribute(Product.Attributes.SOCKETS, "4");
pdata.setAttribute(Product.Attributes.RAM, "8");
pdata.setAttribute(Product.Attributes.CORES, "4");
pdata.setAttribute(Product.Attributes.MANAGEMENT_ENABLED, "true");
pdata.setAttribute(Product.Attributes.STACKING_ID, "45678");
entitlement.getPool().setAttribute(Product.Attributes.VIRT_ONLY, "true");
pdata.setAttribute(Product.Attributes.SUPPORT_LEVEL, "slevel");
pdata.setAttribute(Product.Attributes.SUPPORT_TYPE, "stype");
subscription.setAccountNumber("account1");
subscription.setContractNumber("contract1");
subscription.setOrderNumber("order1");
if (pdata.getProductContent() != null) {
for (ProductContentData pcd : pdata.getProductContent()) {
pcd.setEnabled(false);
}
}
}
use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.
the class TestUtil method createSubscription.
public static Subscription createSubscription(Owner owner, ProductData dto, Collection<ProductData> providedProductsData) {
Set<ProductData> providedProductsSet = new HashSet<>();
providedProductsSet.addAll(providedProductsData);
Subscription sub = new Subscription(owner, dto, providedProductsSet, 1000L, createDate(2000, 1, 1), createDate(2050, 1, 1), createDate(2000, 1, 1));
sub.setId("test-sub-" + randomInt());
return sub;
}
use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.
the class TestUtil method copyFromSub.
/**
* Returns a pool which will look like it was created from the given subscription
* during refresh pools.
*
* @param sub source subscription
* @return pool for subscription
*/
public static Pool copyFromSub(Subscription sub) {
Product product = createProduct((ProductData) sub.getProduct());
Product derivedProduct = createProduct((ProductData) sub.getDerivedProduct());
List<Product> providedProducts = new LinkedList<>();
if (sub.getProvidedProducts() != null) {
for (ProductData pdata : sub.getProvidedProducts()) {
if (pdata != null) {
providedProducts.add(TestUtil.createProduct(pdata));
}
}
}
List<Product> derivedProvidedProducts = new LinkedList<>();
if (sub.getDerivedProvidedProducts() != null) {
for (ProductData pdata : sub.getDerivedProvidedProducts()) {
if (pdata != null) {
derivedProvidedProducts.add(TestUtil.createProduct(pdata));
}
}
}
Pool pool = new Pool(sub.getOwner(), product, providedProducts, sub.getQuantity(), sub.getStartDate(), sub.getEndDate(), sub.getContractNumber(), sub.getAccountNumber(), sub.getOrderNumber());
pool.setDerivedProduct(derivedProduct);
pool.setDerivedProvidedProducts(derivedProvidedProducts);
if (sub.getId() != null) {
pool.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
}
pool.setUpstreamPoolId(sub.getUpstreamPoolId());
pool.setUpstreamConsumerId(sub.getUpstreamConsumerId());
pool.setUpstreamEntitlementId(sub.getUpstreamEntitlementId());
for (Branding branding : sub.getBranding()) {
pool.getBranding().add(new Branding(branding.getProductId(), branding.getType(), branding.getName()));
}
return pool;
}
use of org.candlepin.model.dto.ProductData in project candlepin by candlepin.
the class ProductDataTranslatorTest method initSourceObject.
@Override
protected ProductData initSourceObject() {
ProductData source = new ProductData();
Map<String, String> attributes = new HashMap<>();
attributes.put("attrib_1", "attrib_value_1");
attributes.put("attrib_2", "attrib_value_2");
attributes.put("attrib_3", "attrib_value_3");
Collection<String> depProdIds = new LinkedList<>();
depProdIds.add("dep_prod_1");
depProdIds.add("dep_prod_2");
depProdIds.add("dep_prod_3");
source.setUuid("test_uuid");
source.setId("test_id");
source.setName("test_name");
source.setMultiplier(10L);
source.setAttributes(attributes);
source.setDependentProductIds(depProdIds);
source.setLocked(true);
for (int i = 0; i < 3; ++i) {
Content content = TestUtil.createContent("content-" + i);
content.setUuid(content.getId() + "_uuid");
source.addContent(content, true);
}
return source;
}
use of org.candlepin.model.dto.ProductData 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());
}
Aggregations