use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method rangeRelativeToDate.
private DateRange rangeRelativeToDate(Date relativeTo, int startMonths, int endMonths) {
Calendar cal = Calendar.getInstance();
cal.setTime(relativeTo);
cal.add(Calendar.MONTH, startMonths);
Date start = cal.getTime();
cal.setTime(relativeTo);
cal.add(Calendar.MONTH, endMonths);
Date end = cal.getTime();
DateRange dr = new DateRange();
dr.setEndDate(Util.toDateTime(end));
dr.setStartDate(Util.toDateTime(start));
return dr;
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIgnoresExpiredWithNoOverlap.
@Test
public void validRangeIgnoresExpiredWithNoOverlap() {
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, -6, -3);
DateRange range2 = this.rangeRelativeToDate(now, -1, 6);
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(range2.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeForSingleValidEnitlement.
@Test
public void validRangeForSingleValidEnitlement() {
Owner owner = TestUtil.createOwner();
owner.setContentAccessMode("entitlement");
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
DateRange range = this.rangeRelativeToDate(new Date(), -6, 6);
Entitlement entitlement = this.mockEntitlement(owner, consumer, product, range, product);
consumer.addEntitlement(entitlement);
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(Util.toDate(range.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeWithMultipleWhereOneConsumesTheOthersSpan.
@Test
public void validRangeWithMultipleWhereOneConsumesTheOthersSpan() {
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, 0, 2);
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(range1.getEndDate()), cip.getEndDate());
}
use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIgnoresFutureWithNoOverlap.
@Test
public void validRangeIgnoresFutureWithNoOverlap() {
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, 6, 12);
DateRange range2 = this.rangeRelativeToDate(now, -1, 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(Util.toDate(range2.getStartDate()), cip.getStartDate());
assertEquals(Util.toDate(range2.getEndDate()), cip.getEndDate());
}
Aggregations