use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProductNoChange.
@Test
public void testUpdateProductNoChange() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Product product = this.createProduct("p1", "prod1", owner);
Product output = this.productManager.updateProduct(product.toDTO(), owner, true);
assertEquals(output.getUuid(), product.getUuid());
assertEquals(output, product);
verifyZeroInteractions(this.mockEntCertGenerator);
}
use of org.candlepin.model.Owner 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.Owner 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);
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class X509V3ExtensionUtilTest method testPrefixLogic.
@Test
public void testPrefixLogic() {
Owner owner = new Owner("Test Corporation");
Product p = new Product("JarJar", "Binks");
Content c = new Content();
c.setContentUrl("/some/path");
ProductContent pc = new ProductContent(p, c, true);
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
c.setContentUrl("some/path");
assertEquals("/some/path", util.createFullContentPath(null, pc));
assertEquals("/some/path", util.createFullContentPath("", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
c.setContentUrl("///////some/path");
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
assertEquals("/some/path", util.createFullContentPath(null, pc));
assertEquals("/some/path", util.createFullContentPath("", pc));
c.setContentUrl("http://some/path");
assertEquals("http://some/path", util.createFullContentPath("/this/is", pc));
c.setContentUrl("https://some/path");
assertEquals("https://some/path", util.createFullContentPath("/this/is", pc));
c.setContentUrl("ftp://some/path");
assertEquals("ftp://some/path", util.createFullContentPath("/this/is", pc));
c.setContentUrl("file://some/path");
assertEquals("file://some/path", util.createFullContentPath("/this/is", pc));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class EntitlementCertificateGeneratorTest method testNonLazyRegenerationByEntitlementId.
@Test
public void testNonLazyRegenerationByEntitlementId() throws Exception {
Owner owner = TestUtil.createOwner("test-owner", "Test Owner");
Consumer consumer = TestUtil.createConsumer(owner);
Product product = TestUtil.createProduct();
Pool pool = TestUtil.createPool(owner, product);
Entitlement entitlement = TestUtil.createEntitlement(owner, consumer, pool, null);
entitlement.setId("test-ent-id");
Collection<String> entitlements = Arrays.asList(entitlement.getId());
pool.setEntitlements(new HashSet(Arrays.asList(entitlement)));
HashMap<String, EntitlementCertificate> ecMap = new HashMap<>();
ecMap.put(pool.getId(), new EntitlementCertificate());
when(this.mockEntitlementCurator.find(eq(entitlement.getId()))).thenReturn(entitlement);
when(this.mockEntCertAdapter.generateEntitlementCerts(any(Consumer.class), any(Map.class), any(Map.class), any(Map.class), eq(true))).thenReturn(ecMap);
this.ecGenerator.regenerateCertificatesByEntitlementIds(entitlements, false);
assertFalse(entitlement.isDirty());
verify(this.mockEntCertAdapter, times(1)).generateEntitlementCerts(any(Consumer.class), this.poolQuantityMapCaptor.capture(), this.entMapCaptor.capture(), this.productMapCaptor.capture(), eq(true));
verify(this.mockEventSink, times(1)).queueEvent(any(Event.class));
}
Aggregations