use of org.candlepin.model.Product in project candlepin by candlepin.
the class PoolTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Pool source, PoolDTO dest, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dest.getId());
assertEquals(source.getType().toString(), dest.getType());
assertEquals(source.getActiveSubscription(), dest.isActiveSubscription());
assertEquals(source.isCreatedByShare(), dest.isCreatedByShare());
assertEquals(source.hasSharedAncestor(), dest.hasSharedAncestor());
assertEquals(source.getQuantity(), dest.getQuantity());
assertEquals(source.getStartDate(), dest.getStartDate());
assertEquals(source.getEndDate(), dest.getEndDate());
assertEquals(source.getAttributes(), dest.getAttributes());
assertEquals(source.getRestrictedToUsername(), dest.getRestrictedToUsername());
assertEquals(source.getContractNumber(), dest.getContractNumber());
assertEquals(source.getAccountNumber(), dest.getAccountNumber());
assertEquals(source.getOrderNumber(), dest.getOrderNumber());
assertEquals(source.getConsumed(), dest.getConsumed());
assertEquals(source.getExported(), dest.getExported());
assertEquals(source.getShared(), dest.getShared());
assertEquals(source.getCalculatedAttributes(), dest.getCalculatedAttributes());
assertEquals(source.getUpstreamPoolId(), dest.getUpstreamPoolId());
assertEquals(source.getUpstreamEntitlementId(), dest.getUpstreamEntitlementId());
assertEquals(source.getUpstreamConsumerId(), dest.getUpstreamConsumerId());
assertEquals(source.getProductName(), dest.getProductName());
assertEquals(source.getProductId(), dest.getProductId());
assertEquals(source.getProductAttributes(), dest.getProductAttributes());
assertEquals(source.getStackId(), dest.getStackId());
assertEquals(source.isStacked(), dest.isStacked());
assertEquals(source.isDevelopmentPool(), dest.isDevelopmentPool());
assertEquals(source.getDerivedProductAttributes(), dest.getDerivedProductAttributes());
assertEquals(source.getDerivedProductId(), dest.getDerivedProductId());
assertEquals(source.getDerivedProductName(), dest.getDerivedProductName());
assertEquals(source.getSourceStackId(), dest.getSourceStackId());
assertEquals(source.getSubscriptionSubKey(), dest.getSubscriptionSubKey());
assertEquals(source.getSubscriptionId(), dest.getSubscriptionId());
if (childrenGenerated) {
this.ownerTranslatorTest.verifyOutput(source.getOwner(), dest.getOwner(), true);
this.certificateTranslatorTest.verifyOutput(source.getCertificate(), dest.getCertificate(), true);
Entitlement sourceSourceEntitlement = source.getSourceEntitlement();
EntitlementDTO destSourceEntitlement = dest.getSourceEntitlement();
if (sourceSourceEntitlement != null) {
assertEquals(sourceSourceEntitlement.getId(), destSourceEntitlement.getId());
} else {
assertNull(destSourceEntitlement);
}
for (Branding brandingSource : source.getBranding()) {
for (BrandingDTO brandingDTO : dest.getBranding()) {
assertNotNull(brandingDTO);
assertNotNull(brandingDTO.getProductId());
if (brandingDTO.getProductId().equals(brandingSource.getProductId())) {
this.brandingTranslatorTest.verifyOutput(brandingSource, brandingDTO, true);
}
}
}
Set<Product> sourceProducts = source.getProvidedProducts();
Set<PoolDTO.ProvidedProductDTO> productsDTO = dest.getProvidedProducts();
verifyProductsOutput(sourceProducts, productsDTO);
Set<Product> sourceDerivedProducts = source.getDerivedProvidedProducts();
Set<PoolDTO.ProvidedProductDTO> derivedProductsDTO = dest.getDerivedProvidedProducts();
verifyProductsOutput(sourceDerivedProducts, derivedProductsDTO);
} else {
assertNull(dest.getOwner());
assertNull(dest.getSourceEntitlement());
assertNull(dest.getBranding());
assertNull(dest.getProvidedProducts());
assertNull(dest.getDerivedProvidedProducts());
assertNull(dest.getCertificate());
}
} else {
assertNull(dest);
}
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class ProductTranslatorTest method initSourceObject.
@Override
protected Product initSourceObject() {
Product source = new Product();
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.setId("test_id");
source.setName("test_name");
source.setAttributes(attributes);
source.setDependentProductIds(depProdIds);
source.setUuid("test_uuid");
source.setMultiplier(3L);
for (int i = 0; i < 3; ++i) {
Content content = TestUtil.createContent("content-" + i);
source.addContent(content, true);
}
return source;
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class PoolTranslatorTest method initSourceObject.
@Override
protected Pool initSourceObject() {
Pool source = new Pool();
source.setId("pool-id");
source.setHasSharedAncestor(true);
source.setQuantity(1L);
source.setStartDate(new Date());
source.setEndDate(new Date());
Map<String, String> attributes = new HashMap<>();
attributes.put(Pool.Attributes.SOURCE_POOL_ID, "true");
source.setAttributes(attributes);
source.setRestrictedToUsername("restricted-to-username-value");
source.setConsumed(6L);
source.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
Product derivedProduct = new Product();
derivedProduct.setId("derived-product-id-2");
derivedProduct.setName("derived-product-name-2");
derivedProduct.setAttributes(new HashMap<>());
derivedProduct.setAttribute(Product.Attributes.ARCHITECTURE, "POWER");
derivedProduct.setAttribute(Product.Attributes.STACKING_ID, "2221");
source.setDerivedProduct(derivedProduct);
ProvidedProduct providedProd = new ProvidedProduct();
providedProd.setProductId("provided-product-id-1");
providedProd.setProductName("provided-product-name-1");
Set<ProvidedProduct> providedProducts = new HashSet<>();
providedProducts.add(providedProd);
source.setProvidedProductDtos(providedProducts);
ProvidedProduct derivedProvidedProd = new ProvidedProduct();
derivedProvidedProd.setProductId("derived-provided-product-id-1");
derivedProvidedProd.setProductName("derived-provided-product-name-1");
Set<ProvidedProduct> derivedProvidedProducts = new HashSet<>();
derivedProvidedProducts.add(derivedProvidedProd);
source.setDerivedProvidedProductDtos(derivedProvidedProducts);
return source;
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class X509V3ExtensionUtilTest method productWithBrandName.
@Test
public void productWithBrandName() {
String engProdId = "1000";
String brandedName = "Branded Eng Product";
Owner owner = new Owner("Test Corporation");
Product p = new Product(engProdId, "Eng Product 1000");
p.setAttribute(Product.Attributes.BRANDING_TYPE, "OS");
Set<Product> prods = new HashSet<>(Arrays.asList(p));
Product mktProd = new Product("mkt", "MKT SKU");
Pool pool = TestUtil.createPool(mktProd);
pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
Consumer consumer = new Consumer();
Entitlement e = new Entitlement(pool, consumer, owner, 10);
List<org.candlepin.model.dto.Product> certProds = util.createProducts(mktProd, prods, "", new HashMap<>(), new Consumer(), pool);
assertEquals(1, certProds.size());
assertEquals(brandedName, certProds.get(0).getBrandName());
assertEquals("OS", certProds.get(0).getBrandType());
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class X509V3ExtensionUtilTest method productWithMultipleBrandNames.
@Test
public void productWithMultipleBrandNames() {
String engProdId = "1000";
String brandedName = "Branded Eng Product";
Owner owner = new Owner("Test Corporation");
Product p = new Product(engProdId, "Eng Product 1000");
p.setAttribute(Product.Attributes.BRANDING_TYPE, "OS");
Set<Product> prods = new HashSet<>(Arrays.asList(p));
Product mktProd = new Product("mkt", "MKT SKU");
Pool pool = TestUtil.createPool(mktProd);
pool.getBranding().add(new Branding(engProdId, "OS", brandedName));
pool.getBranding().add(new Branding(engProdId, "OS", "another brand name"));
pool.getBranding().add(new Branding(engProdId, "OS", "number 3"));
Set<String> possibleBrandNames = new HashSet<>();
for (Branding b : pool.getBranding()) {
possibleBrandNames.add(b.getName());
}
List<org.candlepin.model.dto.Product> certProds = util.createProducts(mktProd, prods, "", new HashMap<>(), new Consumer(), pool);
assertEquals(1, certProds.size());
// Should get the first name we encountered
// but they're in a set so we can't test order
String resultBrandName = certProds.get(0).getBrandName();
String resultBrandType = certProds.get(0).getBrandType();
assertTrue(possibleBrandNames.contains(resultBrandName));
assertEquals("OS", resultBrandType);
}
Aggregations