use of org.candlepin.policy.js.compliance.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeConsidersInvalidGapBetweenNonStackedAndPartialEntitlement.
@Test
public void validRangeConsidersInvalidGapBetweenNonStackedAndPartialEntitlement() {
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, -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", product, 1, range2, product));
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range3, product));
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(range3.getStartDate(), cip.getStartDate());
assertEquals(range2.getEndDate(), cip.getEndDate());
}
use of org.candlepin.policy.js.compliance.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIsNullWhenOnlyFutureEntitlementExists.
@Test
public void validRangeIsNullWhenOnlyFutureEntitlementExists() {
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.policy.js.compliance.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeForUnmappedGuestEntitlement.
@Test
public void validRangeForUnmappedGuestEntitlement() {
Date now = new Date();
Owner owner = TestUtil.createOwner();
Product product = TestUtil.createProduct("p1", "product1");
Consumer consumer = this.mockConsumer(owner, product);
consumer.setCreated(now);
DateRange range = this.rangeRelativeToDate(now, -6, 6);
Entitlement entitlement = this.mockUnmappedGuestEntitlement(owner, consumer, product, range, product);
consumer.addEntitlement(entitlement);
this.mockConsumerEntitlements(consumer, consumer.getEntitlements());
this.mockOwnerProducts(owner, Arrays.asList(product));
this.consumerEnricher.enrich(consumer);
Date expectedEnd = new Date(now.getTime() + (24 * 60 * 60 * 1000));
ConsumerInstalledProduct cip = this.getInstalledProduct(consumer, product);
assertEquals(range.getStartDate(), cip.getStartDate());
assertEquals(expectedEnd, cip.getEndDate());
}
use of org.candlepin.policy.js.compliance.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method multiEntGreenNowYellowFutureWithOverlap.
@Test
public void multiEntGreenNowYellowFutureWithOverlap() {
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, 12);
DateRange range2 = this.rangeRelativeToDate(now, 11, 24);
consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range1, product));
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(range1.getStartDate(), cip.getStartDate());
assertEquals(range1.getEndDate(), cip.getEndDate());
}
use of org.candlepin.policy.js.compliance.DateRange in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method validRangeIgnoresFutureBackToBack.
@Test
public void validRangeIgnoresFutureBackToBack() {
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, 12, 24);
DateRange range2 = this.rangeRelativeToDate(now, 0, 12);
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(range2.getStartDate(), cip.getStartDate());
assertEquals(range1.getEndDate(), cip.getEndDate());
}
Aggregations