From 4b8d4a84b653d1d49d8bfbcf55d6a4b0c0d41de4 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Fri, 9 Apr 2021 11:58:05 +0200 Subject: [PATCH] Set the NumberGenerator for th remaining tests --- .../services/youtube/YoutubeChannelLocalizationTest.java | 2 ++ .../extractor/services/youtube/YoutubeParsingHelperTest.java | 2 ++ .../services/youtube/YoutubeSuggestionExtractorTest.java | 2 ++ .../services/youtube/YoutubeTrendingKioskInfoTest.java | 3 +++ .../stream/YoutubeStreamExtractorAgeRestrictedTest.java | 4 +++- .../youtube/stream/YoutubeStreamExtractorLivestreamTest.java | 2 ++ .../youtube/stream/YoutubeStreamExtractorUnlistedTest.java | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java index 6e4b80cb..d4b058c8 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java @@ -14,6 +14,7 @@ import java.time.temporal.ChronoUnit; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Random; import static org.junit.Assert.fail; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -30,6 +31,7 @@ public class YoutubeChannelLocalizationTest { @Test public void testAllSupportedLocalizations() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "localization")); testLocalizationsFor("https://www.youtube.com/user/NBCNews"); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java index 39af59e1..144d779d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java @@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.io.IOException; +import java.util.Random; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -19,6 +20,7 @@ public class YoutubeParsingHelperTest { @BeforeClass public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "youtubeParsingHelper")); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java index f4818b2f..1f9b0c37 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java @@ -29,6 +29,7 @@ import org.schabi.newpipe.extractor.localization.Localization; import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor; import java.io.IOException; +import java.util.Random; import static org.junit.Assert.assertFalse; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -45,6 +46,7 @@ public class YoutubeSuggestionExtractorTest { @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + ""), new Localization("de", "DE")); suggestionExtractor = YouTube.getSuggestionExtractor(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java index f4fd2d23..9469cd1a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java @@ -28,6 +28,8 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.kiosk.KioskInfo; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; +import java.util.Random; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -45,6 +47,7 @@ public class YoutubeTrendingKioskInfoTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH)); LinkHandlerFactory LinkHandlerFactory = ((StreamingService) YouTube).getKioskList().getListLinkHandlerFactoryByType("Trending"); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java index 63fa3411..6d74e4fa 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; import java.util.Arrays; import java.util.List; +import java.util.Random; import javax.annotation.Nullable; @@ -26,7 +27,8 @@ public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtrac @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "ageRestricted")); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "ageRestricted")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java index 01de7949..936a6993 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; import java.util.Arrays; import java.util.List; +import java.util.Random; import javax.annotation.Nullable; @@ -26,6 +27,7 @@ public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractor @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "live")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java index 83bd8ae7..267de4f4 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamType; import java.util.Arrays; import java.util.List; +import java.util.Random; import javax.annotation.Nullable; @@ -25,6 +26,7 @@ public class YoutubeStreamExtractorUnlistedTest extends DefaultStreamExtractorTe @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); + YoutubeParsingHelper.setNumberGenerator(new Random(1)); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "unlisted")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage();