use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeNotNullWhenOnlyPartialEntitlement.
// Stacking becomes involved here.
@Test
public void validRangeNotNullWhenOnlyPartialEntitlement() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
owner.setContentAccessMode("entitlement");
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, 4);
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range1, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(Util.toDate(range1.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range1.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeConsidersInvalidGapBetweenNonStackedEntitlement.
@Test
public void validRangeConsidersInvalidGapBetweenNonStackedEntitlement() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
owner.setContentAccessMode("entitlement");
Product product = TestUtil.createProduct("p1", "product1");
Product stacked = TestUtil.createProduct("p1_stack", "product1-stacked");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, -2);
DateRange range2 = this.rangeRelativeToDate(now, -3, 2);
DateRange range3 = this.rangeRelativeToDate(now, -1, 4);
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range1, product));
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", stacked, 1, range2, product));
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range3, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(Util.toDate(range3.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range3.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method cannotStackFutureSubs.
@Test
public void cannotStackFutureSubs() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
owner.setContentAccessMode("entitlement");
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, 12);
DateRange range2 = this.rangeRelativeToDate(Util.toDate(range1.getEndDate()), 5, 6);
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range1, product));
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range2, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
ComplianceStatus status = complianceRules.getStatus(consumer, now);
assertEquals("partial", status.getStatus());
assertTrue(status.getPartialStacks().containsKey("stack_id_1"));
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeWhenStackedButOneProvides.
// Test valid range with a full stack where one stacked entitlement provides the product
@Test
public void validRangeWhenStackedButOneProvides() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
owner.setContentAccessMode("entitlement");
Product product = TestUtil.createProduct("p1", "product1");
Product product2 = TestUtil.createProduct("p2", "product2");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range1 = this.rangeRelativeToDate(now, -4, 4);
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range1, product));
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product2, 1, range1, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(Util.toDate(range1.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range1.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method enricherDoesntSetArchVersion.
@Test
public void enricherDoesntSetArchVersion() {
// test that the enricher does not set the arch and version when they are populated
// in the CIP
Owner owner = TestUtil.createOwner();
owner.setId(TestUtil.randomString());
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
DateRange range = this.rangeRelativeToDate(new Date(), -1, 4);
Entitlement entitlement = this.mockEntitlement(owner, consumer, product, range, product);
consumer.addEntitlement(entitlement);
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
ConsumerInstalledProduct cip = new ConsumerInstalledProduct();
cip.setProductId(product.getId());
consumer.addInstalledProduct(cip);
this.mockOwnerProducts(owner, Arrays.asList(product));
// Set these to non-null values to show they aren't overwritten
cip.setArch("original arch");
cip.setVersion("original version");
product.setAttribute(Product.Attributes.ARCHITECTURE, "candlepin arch");
product.setAttribute(Product.Attributes.VERSION, "candlepin version");
this.consumerEnricher.enrich(consumer);
assertEquals("original arch", cip.getArch());
assertEquals("original version", cip.getVersion());
}
Aggregations