示例#1
0
  @Test
  public void testMergesHDandSDforFilms() {
    BtVodEntry btVodEntrySD = filmRow("About Alex");
    btVodEntrySD.setProductTargetBandwidth("SD");

    BtVodEntry btVodEntryHD = filmRow("About Alex - HD");
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");
    btVodEntryHD.setProductTargetBandwidth("HD");

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());

    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.<ParentRef>absent());
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.<ParentRef>absent());

    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.<Series>absent());
    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.<Series>absent());

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is("About Alex"));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));

    assertThat(writtenItem.getVersions().size(), is(2));

    Version hdVersion = Iterables.get(writtenItem.getVersions(), 0);
    Version sdVersion = Iterables.get(writtenItem.getVersions(), 1);
    assertThat(
        Iterables.getOnlyElement(sdVersion.getManifestedAs()).getHighDefinition(), is(false));
    assertThat(Iterables.getOnlyElement(hdVersion.getManifestedAs()).getHighDefinition(), is(true));
  }
示例#2
0
  @Test
  public void testMergesFilmsFromCurzon() {
    BtVodEntry btVodEntrySD = filmRow("Amour");

    BtVodEntry btVodEntryHD = filmRow("Amour (Curzon)");
    btVodEntryHD.setGuid(PRODUCT_GUID + "Curzon");

    BtVodEntry btVodEntryHDCurzon = filmRow("Amour (Curzon) - HD");
    btVodEntryHDCurzon.setGuid(PRODUCT_GUID + "Curzon_HD");

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());

    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.<ParentRef>absent());
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.<ParentRef>absent());
    when(btVodBrandProvider.brandRefFor(btVodEntryHDCurzon))
        .thenReturn(Optional.<ParentRef>absent());

    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.<Series>absent());
    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.<Series>absent());
    when(seriesProvider.seriesFor(btVodEntryHDCurzon)).thenReturn(Optional.<Series>absent());

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);
    itemExtractor.process(btVodEntryHDCurzon);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is("Amour"));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));

    assertThat(writtenItem.getVersions().size(), is(3));
  }
示例#3
0
  @Test
  public void testMergesAndDedupesTopicsAcrossVariants() {
    BtVodEntry btVodEntrySD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    ParentRef parentRef = new ParentRef(BRAND_URI);
    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    BtVodEntry btVodEntryHD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntryHD.setTitle(FULL_EPISODE_TITLE + " - HD");
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");

    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.of(series));
    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.of(series));

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.of(parentRef));
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.of(parentRef));
    when(newTopicContentMatchingPredicate.apply(isA(VodEntryAndContent.class))).thenReturn(true);
    when(kidsTopicPredicate.apply(argThat(new VodEntryHasGuid(btVodEntryHD.getGuid()))))
        .thenReturn(true);

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTopicRefs().size(), is(2));
  }
示例#4
0
  @Test
  public void testMergesVersionsForHDandSD() {
    BtVodEntry btVodEntrySD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    ParentRef parentRef = new ParentRef(BRAND_URI);
    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    BtVodEntry btVodEntryHD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntryHD.setTitle(FULL_EPISODE_TITLE + " - HD");
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");

    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.of(series));
    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.of(series));

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.of(parentRef));
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.of(parentRef));

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is(REAL_EPISODE_TITLE));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));
    assertThat(writtenItem.getContainer(), is(parentRef));

    assertThat(writtenItem.getVersions().size(), is(2));
    assertThat(writtenItem.getClips().size(), is(2));
  }
示例#5
0
  private BtVodEntry vodEntryWithPricingTiers(Iterable<BtVodProductPricingTier> tiers) {
    BtVodEntry entry = new BtVodEntry();
    BtVodProductPricingPlan plan = new BtVodProductPricingPlan();
    plan.setProductPricingTiers(ImmutableList.copyOf(tiers));
    entry.setProductPricingPlan(plan);

    return entry;
  }
示例#6
0
  @Test
  public void testMergesImagesAndDescriptionsForHDAndSD() {
    BtVodEntry btVodEntrySD = filmRow("About Alex");
    btVodEntrySD.setProductTargetBandwidth("SD");
    btVodEntrySD.setDescription("sd");
    btVodEntrySD.setProductLongDescription("sdLong");

    BtVodEntry btVodEntryHD = filmRow("About Alex - HD");
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");
    btVodEntryHD.setProductTargetBandwidth("HD");
    btVodEntryHD.setDescription("hd");
    btVodEntryHD.setProductLongDescription("hdLong");

    Image sdImage = new Image("sdImage");
    Image hdImage = new Image("hdImage");

    when(imageExtractor.imagesFor(btVodEntrySD)).thenReturn(ImmutableSet.of(sdImage));
    when(imageExtractor.imagesFor(btVodEntryHD)).thenReturn(ImmutableSet.of(hdImage));

    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.<ParentRef>absent());
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.<ParentRef>absent());

    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.<Series>absent());
    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.<Series>absent());

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item item = Iterables.get(itemExtractor.getProcessedItems().values(), 0);

    verify(descriptionAndImageUpdater)
        .updateDescriptionsAndImages(
            eq(item), eq(btVodEntryHD), eq(ImmutableSet.of(hdImage)), anySet());
  }
示例#7
0
  @Test
  public void testExtractsEpisode() {
    BtVodEntry btVodEntry = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    ParentRef parentRef = new ParentRef(BRAND_URI);
    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(series));

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntry)).thenReturn(Optional.of(parentRef));

    itemExtractor.process(btVodEntry);
    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is(REAL_EPISODE_TITLE));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));
    assertThat(writtenItem.getContainer(), is(parentRef));

    Location location =
        Iterables.getOnlyElement(
            Iterables.getOnlyElement(
                    Iterables.getOnlyElement(writtenItem.getVersions()).getManifestedAs())
                .getAvailableAt());

    DateTime expectedAvailabilityStart =
        new DateTime(2013, DateTimeConstants.APRIL, 1, 0, 0, 0, 0, DateTimeZone.UTC);
    DateTime expectedAvailabilityEnd =
        new DateTime(2014, DateTimeConstants.APRIL, 30, 0, 0, 0, 0, DateTimeZone.UTC);
    assertThat(location.getPolicy().getAvailabilityStart(), is(expectedAvailabilityStart));
    assertThat(location.getPolicy().getAvailabilityEnd(), is(expectedAvailabilityEnd));
    assertThat(
        location.getPolicy().getSubscriptionPackages(),
        is((Set<String>) ImmutableSet.of(SUBSCRIPTION_CODE)));
    assertThat(
        Iterables.getOnlyElement(writtenItem.getClips()),
        is(new Clip(TRAILER_URI, TRAILER_URI, Publisher.BT_VOD)));

    Set<Alias> expectedAliases =
        ImmutableSet.of(
            new Alias(BT_VOD_GUID_NAMESPACE, btVodEntry.getGuid()),
            new Alias(BT_VOD_ID_NAMESPACE, btVodEntry.getId()));

    assertThat(writtenItem.getAliases(), is(expectedAliases));
    assertThat(
        Iterables.getOnlyElement(location.getPolicy().getAvailableCountries()).code(), is("GB"));
    assertThat(location.getPolicy().getRevenueContract(), is(RevenueContract.SUBSCRIPTION));
  }
示例#8
0
  @Test
  public void testDoesNotCreatePayToXLocationsWithZeroPrice() {
    BtVodEntry btVodEntry =
        episodeRow(SERIES_TITLE + ": S1 S1-E9 " + REAL_EPISODE_TITLE, PRODUCT_GUID);

    btVodEntry.setProductOfferingType("type-EST");

    BtVodProductPricingPlan pricingPlan = new BtVodProductPricingPlan();

    BtVodProductPricingTier pricingTier = new BtVodProductPricingTier();
    pricingTier.setProductAbsoluteStart(DateTime.now().minusMonths(2).getMillis());
    pricingTier.setProductAbsoluteEnd(DateTime.now().plusMonths(2).getMillis());

    BtVodProductAmounts productAmounts = new BtVodProductAmounts();
    productAmounts.setGBP(0D);

    pricingTier.setProductAmounts(productAmounts);
    pricingPlan.setProductPricingTiers(Lists.newArrayList(pricingTier));
    btVodEntry.setProductPricingPlan(pricingPlan);

    ParentRef parentRef = new ParentRef(BRAND_URI);

    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(series));
    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntry)).thenReturn(Optional.of(parentRef));
    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(series));

    itemExtractor.process(btVodEntry);

    assertThat(itemExtractor.getProcessedItems().size(), is(1));

    Item item = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());
    Version version = Iterables.getOnlyElement(item.getVersions());
    Encoding encoding = Iterables.getOnlyElement(version.getManifestedAs());

    assertThat(encoding.getAvailableAt().size(), is(1));

    Location location = Iterables.getOnlyElement(encoding.getAvailableAt());
    assertThat(
        location.getCanonicalUri().contains(RevenueContract.PAY_TO_BUY.toString()), is(false));
    assertThat(
        location.getCanonicalUri().contains(RevenueContract.PAY_TO_RENT.toString()), is(false));
  }
示例#9
0
  @Test
  @Ignore
  // Ingored until we have real data which allows us to
  // correctly implement availability criteria
  public void testOnlyExtractsTrailerWhenMatchesCriteria() {
    BtVodEntry btVodEntry = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    ParentRef parentRef = new ParentRef(BRAND_URI);

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(mock(Series.class)));
    when(btVodBrandProvider.brandRefFor(btVodEntry)).thenReturn(Optional.of(parentRef));

    btVodEntry.setProductTags(ImmutableList.<BtVodPlproduct$productTag>of());

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertTrue(writtenItem.getClips().isEmpty());
  }
示例#10
0
  private void testHdSdMerging(String hdTitle, String sdTitle, String extractedTitle) {
    BtVodEntry btVodEntrySD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntrySD.setTitle(sdTitle);
    ParentRef parentRef = new ParentRef(BRAND_URI);
    btVodEntrySD.setProductTargetBandwidth("SD");

    BtVodEntry btVodEntryHD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntryHD.setTitle(hdTitle);
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");
    btVodEntryHD.setProductTargetBandwidth("HD");

    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.of(series));
    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.of(series));

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.of(parentRef));
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.of(parentRef));

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is(extractedTitle));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));
    assertThat(writtenItem.getContainer(), is(parentRef));

    assertThat(writtenItem.getVersions().size(), is(2));

    Version hdVersion = Iterables.get(writtenItem.getVersions(), 0);
    Version sdVersion = Iterables.get(writtenItem.getVersions(), 1);
    assertThat(
        Iterables.getOnlyElement(sdVersion.getManifestedAs()).getHighDefinition(), is(false));
    assertThat(Iterables.getOnlyElement(hdVersion.getManifestedAs()).getHighDefinition(), is(true));
    assertThat(
        Iterables.getFirst(writtenItem.getClips(), null),
        is(new Clip(TRAILER_URI, TRAILER_URI, Publisher.BT_VOD)));
  }
示例#11
0
  private BtVodEntry filmRow(String title) {
    BtVodEntry entry = new BtVodEntry();
    entry.setGuid(PRODUCT_GUID);
    entry.setId(PRODUCT_ID);
    entry.setTitle(title);
    entry.setProductOfferStartDate(
        new DateTime(2013, DateTimeConstants.APRIL, 1, 0, 0, 0, 0).getMillis());
    entry.setProductOfferEndDate(
        new DateTime(2014, DateTimeConstants.APRIL, 30, 0, 0, 0).getMillis());
    entry.setDescription(SYNOPSIS);
    entry.setProductType("film");
    entry.setProductPricingPlan(new BtVodProductPricingPlan());
    entry.setProductTrailerMediaId(TRAILER_URI);
    BtVodProductScope productScope = new BtVodProductScope();
    BtVodProductMetadata productMetadata = new BtVodProductMetadata();
    productMetadata.setReleaseYear("2015");
    productScope.setProductMetadata(productMetadata);
    entry.setProductScopes(ImmutableList.of(productScope));
    entry.setProductRatings(ImmutableList.<BtVodProductRating>of());
    BtVodPlproduct$productTag tag = new BtVodPlproduct$productTag();
    tag.setPlproduct$scheme("subscription");
    tag.setPlproduct$title(SUBSCRIPTION_CODE);

    BtVodPlproduct$productTag itemCdnAvailabilityTag = new BtVodPlproduct$productTag();
    itemCdnAvailabilityTag.setPlproduct$scheme("serviceType");
    itemCdnAvailabilityTag.setPlproduct$title("OTG");

    BtVodPlproduct$productTag itemMasterAgreementAvailabilityTag = new BtVodPlproduct$productTag();
    itemMasterAgreementAvailabilityTag.setPlproduct$scheme("masterAgreementOtgTvodPlay");
    itemMasterAgreementAvailabilityTag.setPlproduct$title("TRUE");

    entry.setProductTags(
        ImmutableList.of(tag, itemCdnAvailabilityTag, itemMasterAgreementAvailabilityTag));

    return entry;
  }
示例#12
0
  private BtVodEntry episodeRow(String title, String guid) {
    BtVodEntry entry = new BtVodEntry();
    entry.setGuid(guid);
    entry.setId(PRODUCT_ID);
    entry.setTitle(title);
    entry.setProductOfferStartDate(1364774400000L); // "Apr  1 2013 12:00AM"
    entry.setProductOfferEndDate(1398816000000L); // "Apr 30 2014 12:00AM"
    entry.setDescription(SYNOPSIS);
    entry.setProductType("episode");
    entry.setProductPricingPlan(new BtVodProductPricingPlan());
    entry.setProductTrailerMediaId(TRAILER_URI);
    BtVodProductScope productScope = new BtVodProductScope();
    BtVodProductMetadata productMetadata = new BtVodProductMetadata();
    productMetadata.setEpisodeNumber("1");
    productScope.setProductMetadata(productMetadata);
    entry.setProductScopes(ImmutableList.of(productScope));
    entry.setProductRatings(ImmutableList.<BtVodProductRating>of());
    BtVodPlproduct$productTag tag = new BtVodPlproduct$productTag();
    tag.setPlproduct$scheme("subscription");
    tag.setPlproduct$title(SUBSCRIPTION_CODE);

    BtVodPlproduct$productTag trailerCdnAvailabilityTag = new BtVodPlproduct$productTag();
    trailerCdnAvailabilityTag.setPlproduct$scheme("trailerServiceType");
    trailerCdnAvailabilityTag.setPlproduct$title("OTG");

    BtVodPlproduct$productTag itemCdnAvailabilityTag = new BtVodPlproduct$productTag();
    itemCdnAvailabilityTag.setPlproduct$scheme("serviceType");
    itemCdnAvailabilityTag.setPlproduct$title("OTG");

    BtVodPlproduct$productTag itemMasterAgreementAvailabilityTag = new BtVodPlproduct$productTag();
    itemMasterAgreementAvailabilityTag.setPlproduct$scheme("masterAgreementOtgTvodPlay");
    itemMasterAgreementAvailabilityTag.setPlproduct$title("TRUE");

    entry.setProductTags(
        ImmutableList.of(
            tag,
            trailerCdnAvailabilityTag,
            itemCdnAvailabilityTag,
            itemMasterAgreementAvailabilityTag));

    return entry;
  }