use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIgnoresFutureWithOverlap.
@Test
public void validRangeIgnoresFutureWithOverlap() {
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, 12, 24);
DateRange range2 = this.rangeRelativeToDate(now, 0, 13);
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range2, product));
consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, range1, 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(Util.toDate(range2.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 validRangeWithMultipleWhereExpiredEntitlementOverlaps.
@Test
public void validRangeWithMultipleWhereExpiredEntitlementOverlaps() {
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, 2);
DateRange range2 = this.rangeRelativeToDate(now, -7, -3);
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(Util.toDate(range2.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 validRangeWithMultipleEntsWithOverlap.
@Test
public void validRangeWithMultipleEntsWithOverlap() {
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);
DateRange range2 = this.rangeRelativeToDate(now, 1, 8);
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(Util.toDate(range1.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range2.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method enricherSetsArchVersion.
@Test
public void enricherSetsArchVersion() {
// test that the enricher sets the arch and version when they are null in the CIP
Owner owner = TestUtil.createOwner();
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));
product.setAttribute(Product.Attributes.ARCHITECTURE, "candlepin arch");
product.setAttribute(Product.Attributes.VERSION, "candlepin version");
this.consumerEnricher.enrich(consumer);
assertEquals("candlepin arch", cip.getArch());
assertEquals("candlepin version", cip.getVersion());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeCorrectPartialEntitlementGap.
@Test
public void validRangeCorrectPartialEntitlementGap() {
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);
DateRange range2 = this.rangeRelativeToDate(now, 5, 9);
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));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(Util.toDate(range1.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range1.getEndDate()), cip.getEndDate());
}
Aggregations