Search in sources :

Example 11 with DateRange

use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeConsidersNonStackingEntNotCoveringMachineSocketsInvalid.

@Test
public void validRangeConsidersNonStackingEntNotCoveringMachineSocketsInvalid() {
    Date now = new Date();
    Owner owner = TestUtil.createOwner();
    owner.setContentAccessMode("entitlement");
    Product product = TestUtil.createProduct("p1", "product1");
    Product sockets = TestUtil.createProduct("socketed", "socketed_product");
    sockets.setAttribute(Product.Attributes.SOCKETS, "2");
    Consumer consumer = this.mockConsumer(owner, product);
    consumer.setCreated(now);
    DateRange range1 = this.rangeRelativeToDate(now, -4, 4);
    DateRange range2 = this.rangeRelativeToDate(now, -2, 6);
    consumer.addEntitlement(this.mockEntitlement(owner, consumer, sockets, range1, product));
    consumer.addEntitlement(this.mockEntitlement(owner, consumer, product, 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(range2.getStartDate()), cip.getStartDate());
    assertEquals(Util.toDate(range2.getEndDate()), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.dto.api.v1.DateRange) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 12 with DateRange

use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeCorrectPartialEntitlementNoGap.

@Test
public void validRangeCorrectPartialEntitlementNoGap() {
    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, 4, 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(range2.getEndDate()), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.dto.api.v1.DateRange) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 13 with DateRange

use of com.google.api.ads.admanager.axis.v202205.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());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.dto.api.v1.DateRange) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 14 with DateRange

use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeConsidersInvalidGapBetweenNonStackedAndPartialEntitlement.

@Test
public void validRangeConsidersInvalidGapBetweenNonStackedAndPartialEntitlement() {
    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, -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(Util.toDate(range3.getStartDate()), cip.getStartDate());
    assertEquals(Util.toDate(range2.getEndDate()), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.dto.api.v1.DateRange) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 15 with DateRange

use of com.google.api.ads.admanager.axis.v202205.DateRange in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeEndDateSetToFirstDateOfLosingValidStatus.

@Test
public void validRangeEndDateSetToFirstDateOfLosingValidStatus() {
    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, -2, 10);
    DateRange range3 = this.rangeRelativeToDate(now, -3, -1);
    DateRange range4 = this.rangeRelativeToDate(Util.toDate(range1.getEndDate()), 0, 10);
    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));
    consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range3, product));
    consumer.addEntitlement(this.mockStackedEntitlement(owner, consumer, "stack_id_1", product, 1, range4, 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(range2.getEndDate()), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.dto.api.v1.DateRange) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Product(org.candlepin.model.Product) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

DateRange (org.candlepin.dto.api.v1.DateRange)30 Date (java.util.Date)29 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)27 Product (org.candlepin.model.Product)27 Consumer (org.candlepin.model.Consumer)26 Owner (org.candlepin.model.Owner)26 Test (org.junit.jupiter.api.Test)26 Random (java.util.Random)4 DateTime (org.joda.time.DateTime)4 Interval (org.joda.time.Interval)4 HashSet (java.util.HashSet)3 Entitlement (org.candlepin.model.Entitlement)3 ComplianceStatus (org.candlepin.policy.js.compliance.ComplianceStatus)3 Date (com.google.api.ads.admanager.axis.v202108.Date)2 DateRange (com.google.api.ads.admanager.axis.v202108.DateRange)2 Date (com.google.api.ads.admanager.axis.v202111.Date)2 DateRange (com.google.api.ads.admanager.axis.v202111.DateRange)2 Date (com.google.api.ads.admanager.axis.v202202.Date)2 DateRange (com.google.api.ads.admanager.axis.v202202.DateRange)2 Date (com.google.api.ads.admanager.axis.v202205.Date)2