diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java b/extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java index 124d998d00..3f43b93efc 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java @@ -3,8 +3,11 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -15,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.Utils; public class ExtractorAsserts { @@ -144,6 +148,13 @@ public static void assertContains( assertNotNull(shouldBeContained, "shouldBeContained is null"); assertNotNull(container, "container is null"); assertTrue(container.contains(shouldBeContained), - "'" + shouldBeContained + "' should be contained inside '" + container +"'"); + "'" + shouldBeContained + "' should be contained inside '" + container + "'"); + } + + public static void assertTabs(final List tabs, final String... expect) { + final Set tabSet = tabs.stream() + .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toUnmodifiableSet()); + Arrays.stream(expect).forEach(expectedTab -> assertTrue(tabSet.contains(expectedTab), + String.format("missing tab: %s, got %s", expectedTab, tabSet))); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java index b14a866682..5e124f79ca 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java @@ -5,14 +5,12 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.extractor.ExtractorAsserts; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.linkhandler.ChannelTabs; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; -import java.util.Set; -import java.util.stream.Collectors; - import static org.junit.jupiter.api.Assertions.*; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; @@ -66,9 +64,7 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.ALBUMS), "albums"); + ExtractorAsserts.assertTabs(extractor.getTabs(), ChannelTabs.ALBUMS); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java index 932fbc4256..ddcc1b5576 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java @@ -213,10 +213,7 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.CHANNELS); } } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java index 5b45400541..e23dd94858 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java @@ -250,9 +250,7 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), ChannelTabs.PLAYLISTS); } } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java index 7f4e98da56..00e54737ad 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java @@ -3,22 +3,17 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.extractor.ExtractorAsserts; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.channel.ChannelExtractor; -import org.schabi.newpipe.extractor.channel.ChannelTabExtractor; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ChannelTabs; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor; -import java.util.Set; -import java.util.stream.Collectors; - import static org.junit.jupiter.api.Assertions.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; -import static org.schabi.newpipe.extractor.services.DefaultTests.*; /** * Test for {@link SoundcloudChannelExtractor} @@ -112,11 +107,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.TRACKS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.ALBUMS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS, ChannelTabs.ALBUMS); } } @@ -208,11 +200,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.TRACKS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.ALBUMS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS, ChannelTabs.ALBUMS); } } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YouTubeChannelTabExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YouTubeChannelTabExtractorTest.java index 081689d2c4..3c38ff26bb 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YouTubeChannelTabExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YouTubeChannelTabExtractorTest.java @@ -18,7 +18,7 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; public class YouTubeChannelTabExtractorTest { - private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/channelTab/"; + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/channelTabs/"; public static class Playlists implements BaseListExtractorTest { private static YoutubeChannelTabExtractor extractor; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java index afccc70583..d6398f2925 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java @@ -16,8 +16,6 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor; import java.io.IOException; -import java.util.Set; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains; @@ -258,12 +256,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.LIVESTREAMS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.LIVESTREAMS, ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } @@ -383,13 +377,9 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.SHORTS)); - assertTrue(tabs.contains(ChannelTabs.LIVESTREAMS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.SHORTS, ChannelTabs.LIVESTREAMS, + ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } @@ -511,11 +501,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } @@ -660,11 +647,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } @@ -789,11 +773,8 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } @@ -907,13 +888,9 @@ public void testVerified() throws Exception { @Test @Override public void testTabs() throws Exception { - Set tabs = extractor.getTabs().stream() - .map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet()); - assertTrue(tabs.contains(ChannelTabs.VIDEOS)); - assertTrue(tabs.contains(ChannelTabs.SHORTS)); - assertTrue(tabs.contains(ChannelTabs.LIVESTREAMS)); - assertTrue(tabs.contains(ChannelTabs.PLAYLISTS)); - assertTrue(tabs.contains(ChannelTabs.CHANNELS)); + ExtractorAsserts.assertTabs(extractor.getTabs(), + ChannelTabs.VIDEOS, ChannelTabs.SHORTS, ChannelTabs.LIVESTREAMS, + ChannelTabs.PLAYLISTS, ChannelTabs.CHANNELS); } } } diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_0.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_0.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_0.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_0.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_1.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_1.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_1.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_1.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_2.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_2.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_2.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_2.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_3.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_3.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/channels/generated_mock_3.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/channels/generated_mock_3.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_0.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_0.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_0.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_0.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_1.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_1.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_1.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_1.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_2.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_2.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_2.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_2.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_3.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_3.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/livestreams/generated_mock_3.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/livestreams/generated_mock_3.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_0.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_0.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_0.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_0.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_1.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_1.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_1.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_1.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_2.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_2.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_2.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_2.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_3.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_3.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/playlists/generated_mock_3.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/playlists/generated_mock_3.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_0.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_0.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_0.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_0.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_1.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_1.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_1.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_1.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_2.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_2.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_2.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_2.json diff --git a/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_3.json b/extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_3.json similarity index 100% rename from extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTab/shorts/generated_mock_3.json rename to extractor/src/test/resources/org/schabi/newpipe/extractor/services/youtube/extractor/channelTabs/shorts/generated_mock_3.json