コード例 #1
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));
  }
コード例 #2
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));
  }