use of org.candlepin.model.Product in project candlepin by candlepin.
the class DefaultEntitlementCertServiceAdapterTest method testContentExtensionConsumerNoArchFact.
@Test
public void testContentExtensionConsumerNoArchFact() throws IOException {
Set<Product> products = new HashSet<>();
products.add(product);
// set of content for an incompatible arch, which should
// be in the cert, since this consumer has no arch fact therefore
// should match everything
String wrongArches = "s390";
String noArchUrl = "/some/place/nice";
Content wrongArchContent = createContent(CONTENT_NAME, CONTENT_ID, CONTENT_LABEL, CONTENT_TYPE, CONTENT_VENDOR, noArchUrl, CONTENT_GPG_URL, wrongArches);
product.setProductContent(null);
for (Content content : superContent) {
product.addContent(content, false);
}
product.addContent(wrongArchContent, false);
consumer.setFact("system.certificate_version", "3.3");
Set<X509ByteExtensionWrapper> byteExtensions = certServiceAdapter.prepareV3ByteExtensions(product, getProductModels(product, products, "prefix", entitlement), "prefix", null);
Map<String, X509ByteExtensionWrapper> byteMap = new HashMap<>();
for (X509ByteExtensionWrapper ext : byteExtensions) {
byteMap.put(ext.getOid(), ext);
}
assertTrue(byteMap.containsKey("1.3.6.1.4.1.2312.9.7"));
List<String> contentSetList = new ArrayList<>();
try {
contentSetList = v3extensionUtil.hydrateContentPackage(byteMap.get("1.3.6.1.4.1.2312.9.7").getValue());
} catch (Exception e) {
throw new RuntimeException(e);
}
assertEquals(8, contentSetList.size());
for (String url : testUrls) {
assertTrue(contentSetList.contains("/prefix" + url));
}
// verify our new wrong arch url is in there
assertTrue(contentSetList.contains("/prefix" + noArchUrl));
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class DefaultProductServiceAdapterTest method productsByIds.
@Test
public void productsByIds() {
Owner o = mock(Owner.class);
List<String> ids = new ArrayList<>();
CandlepinQuery<Product> ccmock = mock(CandlepinQuery.class);
ResultIterator<Product> iterator = mock(ResultIterator.class);
when(opc.getProductsByIds(any(Owner.class), anyCollection())).thenReturn(ccmock);
when(ccmock.iterate(anyInt(), anyBoolean())).thenReturn(iterator);
ids.add(someid);
dpsa.getProductsByIds(o, ids);
verify(opc).getProductsByIds(eq(o), eq(ids));
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class CalculatedAttributesUtilTest method testQuantityIncrement.
@Test
public void testQuantityIncrement() {
Product product2 = TestUtil.createProduct("blah", "blah");
product2.setAttribute(Product.Attributes.INSTANCE_MULTIPLIER, "12");
productCurator.create(product2);
Pool pool2 = createPool(owner1, product2, 500L, TestUtil.createDate(2000, 1, 1), TestUtil.createDate(3000, 1, 1));
SuggestedQuantity suggested = new SuggestedQuantity();
suggested.setSuggested(1L);
suggested.setIncrement(12L);
Map<String, SuggestedQuantity> suggestedMap = new HashMap<>();
suggestedMap.put(pool2.getId(), suggested);
when(quantityRules.getSuggestedQuantities(any(List.class), any(Consumer.class), any(Date.class))).thenReturn(suggestedMap);
Date date = new Date();
attrUtil.setQuantityAttributes(pool2, consumer, date);
assertEquals("1", pool2.getCalculatedAttributes().get("suggested_quantity"));
assertEquals("12", pool2.getCalculatedAttributes().get("quantity_increment"));
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIsNullWhenOnlyExpiredEntitlementExists.
@Test
public void validRangeIsNullWhenOnlyExpiredEntitlementExists() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, -2);
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range1, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(null, cip.getStartDate());
assertEquals(null, cip.getEndDate());
}
use of org.candlepin.model.Product in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeWithMultipleWhereFutureEntitlementOverlaps.
@Test
public void validRangeWithMultipleWhereFutureEntitlementOverlaps() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, 2);
DateRange range2 = this.rangeRelativeToDate(now, 2, 4);
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range2, product));
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range1, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(range1.getStartDate(), cip.getStartDate());
assertEquals(range2.getEndDate(), cip.getEndDate());
}
Aggregations