Search in sources :

Example 1 with ConsumerInstalledProduct

use of org.candlepin.model.ConsumerInstalledProduct in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeIsNullWhenOnlyExpiredEntitlementExists.

@Test
public void validRangeIsNullWhenOnlyExpiredEntitlementExists() {
    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.policy.js.compliance.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.Test)

Example 2 with ConsumerInstalledProduct

use of org.candlepin.model.ConsumerInstalledProduct in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeWithMultipleWhereFutureEntitlementOverlaps.

@Test
public void validRangeWithMultipleWhereFutureEntitlementOverlaps() {
    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, 2, 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(range1.getStartDate(), cip.getStartDate());
    assertEquals(range2.getEndDate(), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.policy.js.compliance.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.Test)

Example 3 with ConsumerInstalledProduct

use of org.candlepin.model.ConsumerInstalledProduct in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeConsidersInvalidGapBetweenNonStackedEntitlement.

@Test
public void validRangeConsidersInvalidGapBetweenNonStackedEntitlement() {
    Date now = new Date();
    Owner owner = TestUtil.createOwner();
    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(range3.getStartDate(), cip.getStartDate());
    assertEquals(range3.getEndDate(), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.policy.js.compliance.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.Test)

Example 4 with ConsumerInstalledProduct

use of org.candlepin.model.ConsumerInstalledProduct 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();
    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(range1.getStartDate(), cip.getStartDate());
    assertEquals(range1.getEndDate(), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.policy.js.compliance.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.Test)

Example 5 with ConsumerInstalledProduct

use of org.candlepin.model.ConsumerInstalledProduct in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method validRangeConsidersNonStackingEntNotCoveringMachineSocketsInvalid.

@Test
public void validRangeConsidersNonStackingEntNotCoveringMachineSocketsInvalid() {
    Date now = new Date();
    Owner owner = TestUtil.createOwner();
    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(range2.getStartDate(), cip.getStartDate());
    assertEquals(range2.getEndDate(), cip.getEndDate());
}
Also used : Owner(org.candlepin.model.Owner) DateRange(org.candlepin.policy.js.compliance.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.Test)

Aggregations

ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)66 Consumer (org.candlepin.model.Consumer)54 Product (org.candlepin.model.Product)51 Test (org.junit.Test)49 Owner (org.candlepin.model.Owner)44 Date (java.util.Date)35 DateRange (org.candlepin.policy.js.compliance.DateRange)26 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Entitlement (org.candlepin.model.Entitlement)11 Pool (org.candlepin.model.Pool)11 ConsumerType (org.candlepin.model.ConsumerType)10 AutobindData (org.candlepin.resource.dto.AutobindData)10 HashMap (java.util.HashMap)8 ConsumerCapability (org.candlepin.model.ConsumerCapability)7 List (java.util.List)6 ProductData (org.candlepin.model.dto.ProductData)6 ConsumerInstalledProductDTO (org.candlepin.dto.api.v1.ConsumerInstalledProductDTO)4 Environment (org.candlepin.model.Environment)4 GuestId (org.candlepin.model.GuestId)4