Exemple #1
0
  @Test
  public void testTierMergingTiersNoOverlap() {
    BtVodProductPricingTier tier1 =
        tier(
            new DateTime(2015, DateTimeConstants.FEBRUARY, 1, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.FEBRUARY, 15, 0, 0, 0),
            false);
    BtVodProductPricingTier tier2 =
        tier(
            new DateTime(2015, DateTimeConstants.MARCH, 15, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.APRIL, 1, 0, 0, 0),
            false);

    Multimap<Interval, BtVodProductPricingTier> grouped =
        grouper.groupAvailabilityPeriods(vodEntryWithPricingTiers(ImmutableList.of(tier1, tier2)));

    Collection<BtVodProductPricingTier> firstTierPeriod =
        grouped
            .asMap()
            .get(new Interval(tier1.getProductAbsoluteStart(), tier1.getProductAbsoluteEnd()));
    assertThat(
        Iterables.getOnlyElement(firstTierPeriod).getProductAbsoluteStart(),
        is(tier1.getProductAbsoluteStart()));

    Collection<BtVodProductPricingTier> secondTierPeriod =
        grouped
            .asMap()
            .get(new Interval(tier2.getProductAbsoluteStart(), tier2.getProductAbsoluteEnd()));
    assertThat(
        Iterables.getOnlyElement(secondTierPeriod).getProductAbsoluteStart(),
        is(tier2.getProductAbsoluteStart()));
  }
Exemple #2
0
  @Test
  public void testSingleTier() throws Exception {
    BtVodProductPricingTier tier =
        tier(
            new DateTime(2015, DateTimeConstants.AUGUST, 16, 23, 0, 0, DateTimeZone.UTC),
            new DateTime(2016, DateTimeConstants.APRIL, 16, 12, 59, 0, DateTimeZone.UTC),
            false);

    Multimap<Interval, BtVodProductPricingTier> grouped =
        grouper.groupAvailabilityPeriods(vodEntryWithPricingTiers(ImmutableList.of(tier)));

    assertThat(
        Iterables.getOnlyElement(grouped.values()).getProductAbsoluteStart(),
        is(tier.getProductAbsoluteStart()));

    Entry<Interval, BtVodProductPricingTier> entry = Iterables.getOnlyElement(grouped.entries());
    assertThat(
        entry.getKey().getStart().getMillis(), is(entry.getValue().getProductAbsoluteStart()));
  }
Exemple #3
0
  @Test
  public void testBlackoutTiersAreRemoved() {
    BtVodProductPricingTier tier1 =
        tier(
            new DateTime(2015, DateTimeConstants.FEBRUARY, 1, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.FEBRUARY, 15, 0, 0, 0),
            true);
    BtVodProductPricingTier tier2 =
        tier(
            new DateTime(2015, DateTimeConstants.MARCH, 15, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.APRIL, 1, 0, 0, 0),
            false);

    Multimap<Interval, BtVodProductPricingTier> grouped =
        grouper.groupAvailabilityPeriods(vodEntryWithPricingTiers(ImmutableList.of(tier1, tier2)));

    assertThat(
        Iterables.getOnlyElement(grouped.values()).getProductAbsoluteStart(),
        is(tier2.getProductAbsoluteStart()));
  }
Exemple #4
0
  @Test
  public void testTierMergingTiersAbut() {
    BtVodProductPricingTier tier1 =
        tier(
            new DateTime(2015, DateTimeConstants.FEBRUARY, 1, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.FEBRUARY, 15, 0, 0, 0),
            false);
    BtVodProductPricingTier tier2 =
        tier(
            new DateTime(2015, DateTimeConstants.FEBRUARY, 15, 0, 0, 0),
            new DateTime(2015, DateTimeConstants.MARCH, 1, 0, 0, 0),
            false);

    Multimap<Interval, BtVodProductPricingTier> grouped =
        grouper.groupAvailabilityPeriods(vodEntryWithPricingTiers(ImmutableList.of(tier1, tier2)));

    Entry<Interval, Collection<BtVodProductPricingTier>> onlyElement =
        Iterables.getOnlyElement(grouped.asMap().entrySet());
    assertThat(
        onlyElement.getKey(),
        is(new Interval(tier1.getProductAbsoluteStart(), tier2.getProductAbsoluteEnd())));
    assertThat(onlyElement.getValue().size(), is(2));
  }