Improve assertTabsContain() to also check size
This commit is contained in:
parent
9d0dd36034
commit
4e9e7cb29c
|
@ -171,8 +171,17 @@ public class ExtractorAsserts {
|
|||
public static void assertTabsContain(@Nonnull final List<ListLinkHandler> tabs,
|
||||
@Nonnull final String... expectedTabs) {
|
||||
final Set<String> tabSet = tabs.stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0))
|
||||
.map(linkHandler -> {
|
||||
assertEquals(1, linkHandler.getContentFilters().size(),
|
||||
"Unexpected content filters for channel tab: "
|
||||
+ linkHandler.getContentFilters());
|
||||
return linkHandler.getContentFilters().get(0);
|
||||
})
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
assertEquals(expectedTabs.length, tabSet.size(),
|
||||
"Different amount of tabs returned:\nExpected: "
|
||||
+ Arrays.toString(expectedTabs) + "\nActual: " + tabSet);
|
||||
Arrays.stream(expectedTabs)
|
||||
.forEach(expectedTab -> assertTrue(tabSet.contains(expectedTab),
|
||||
"Missing " + expectedTab + " tab (got " + tabSet + ")"));
|
||||
|
|
|
@ -541,7 +541,8 @@ public class YoutubeChannelExtractorTest {
|
|||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
assertTabsContain(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS);
|
||||
assertTabsContain(extractor.getTabs(),
|
||||
ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS, ChannelTabs.SHORTS);
|
||||
assertTrue(extractor.getTabs().stream()
|
||||
.filter(it -> ChannelTabs.VIDEOS.equals(it.getContentFilters().get(0)))
|
||||
.allMatch(ReadyChannelTabListLinkHandler.class::isInstance));
|
||||
|
@ -920,11 +921,7 @@ public class YoutubeChannelExtractorTest {
|
|||
// Gaming topic channels tabs are not yet supported
|
||||
// However, a Shorts tab like on other channel types is returned, so it is supported
|
||||
// Check that it is returned
|
||||
final List<ListLinkHandler> channelTabs = extractor.getTabs();
|
||||
assertEquals(1, channelTabs.size());
|
||||
final List<String> contentFilters = channelTabs.get(0).getContentFilters();
|
||||
assertEquals(1, contentFilters.size());
|
||||
assertEquals(ChannelTabs.SHORTS, contentFilters.get(0));
|
||||
assertTabsContain(extractor.getTabs(), ChannelTabs.SHORTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue