use of org.candlepin.model.Entitlement 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.Entitlement in project candlepin by candlepin.
the class EntitlementCertificateGeneratorTest method testGenerateEntitlementCertificate.
@Test
public void testGenerateEntitlementCertificate() throws GeneralSecurityException, IOException {
this.ecGenerator = new EntitlementCertificateGenerator(this.mockEntCertCurator, this.mockEntCertAdapter, this.mockEntitlementCurator, this.mockPoolCurator, this.mockEventSink, this.mockEventFactory, this.mockProductCurator);
Consumer consumer = mock(Consumer.class);
Pool pool = mock(Pool.class);
Product product = mock(Product.class);
when(pool.getId()).thenReturn("Swift");
when(pool.getProduct()).thenReturn(product);
Entitlement entitlement = mock(Entitlement.class);
when(entitlement.getConsumer()).thenReturn(consumer);
Map<String, Product> expectedProducts = new HashMap<>();
expectedProducts.put("Swift", product);
Map<String, Entitlement> expected = new HashMap<>();
expected.put("Swift", entitlement);
Map<String, PoolQuantity> poolQuantityMap = new HashMap<>();
poolQuantityMap.put("Swift", new PoolQuantity(pool, 0));
ecGenerator.generateEntitlementCertificate(pool, entitlement);
verify(mockEntCertAdapter).generateEntitlementCerts(eq(consumer), eq(poolQuantityMap), eq(expected), eq(expectedProducts), eq(true));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class EntitlementCertificateGeneratorTest method testLazyRegenerateForEntitlement.
@Test
public void testLazyRegenerateForEntitlement() {
Entitlement entitlement = new Entitlement();
this.ecGenerator.regenerateCertificatesOf(entitlement, true);
assertTrue(entitlement.isDirty());
verifyZeroInteractions(this.mockEntCertAdapter);
}
use of org.candlepin.model.Entitlement 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));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class EntitlementCertificateGeneratorTest method testLazyRegenerateForConsumer.
@Test
public void testLazyRegenerateForConsumer() {
Entitlement entitlement = new Entitlement();
Consumer consumer = new Consumer();
consumer.addEntitlement(entitlement);
this.ecGenerator.regenerateCertificatesOf(consumer, true);
assertTrue(entitlement.isDirty());
verifyZeroInteractions(this.mockEntCertAdapter);
}
Aggregations