@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)); }
@Test public void testUpdatesBrandAndSeriesFromEpisode() { BtVodEntry btVodEntry = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID); ParentRef parentRef = new ParentRef(BRAND_URI); Series series = mock(Series.class); when(series.getCanonicalUri()).thenReturn("seriesUri"); when(series.getSeriesNumber()).thenReturn(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(newTopicContentMatchingPredicate.apply(isA(VodEntryAndContent.class))).thenReturn(true); itemExtractor.process(btVodEntry); Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values()); assertThat(writtenItem.getTopicRefs().contains(newTopicRef), is(true)); verify(btVodBrandProvider).updateBrandFromEpisode(btVodEntry, (Episode) writtenItem); verify(seriesProvider).updateSeriesFromEpisode(btVodEntry, (Episode) writtenItem); }