From f91916c017addeaa49ce15da8f6b37419b1ec649 Mon Sep 17 00:00:00 2001 From: XiangRongLin <41164160+XiangRongLin@users.noreply.github.com> Date: Sun, 10 Jan 2021 20:39:22 +0100 Subject: [PATCH] Remove unnecessary file object creation --- .../newpipe/downloader/DownloaderFactory.java | 4 ++++ .../youtube/YoutubeMixPlaylistExtractorTest.java | 15 +++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java index 4dd996f38..c6fe2b2a6 100644 --- a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java @@ -10,6 +10,10 @@ public class DownloaderFactory { private final static DownloaderType DEFAULT_DOWNLOADER = DownloaderType.REAL; + /** + * @param path The path to the folder where mocks are saved/retrieved. + * Preferably starting with {@link DownloaderFactory#RESOURCE_PATH} + */ public Downloader getDownloader(String path) throws IOException { DownloaderType type; try { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java index 9d42b1bce..1f2939721 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java @@ -54,8 +54,7 @@ public class YoutubeMixPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); - final File file = new File(RESOURCE_PATH + "mix"); - NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath())); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mix")); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor( "https://www.youtube.com/watch?v=" + VIDEO_ID + "&list=RD" + VIDEO_ID); @@ -133,8 +132,7 @@ public class YoutubeMixPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); - final File file = new File(RESOURCE_PATH + "mixWithIndex"); - NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath())); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mixWithIndex")); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor( "https://www.youtube.com/watch?v=" + VIDEO_ID_NUMBER_13 + "&list=RD" @@ -204,8 +202,7 @@ public class YoutubeMixPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); - final File file = new File(RESOURCE_PATH + "myMix"); - NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath())); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "myMix")); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor( "https://www.youtube.com/watch?v=" + VIDEO_ID + "&list=RDMM" @@ -278,8 +275,7 @@ public class YoutubeMixPlaylistExtractorTest { @BeforeClass public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); - final File file = new File(RESOURCE_PATH + "invalid"); - NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath())); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "invalid")); } @Test(expected = IllegalArgumentException.class) @@ -311,8 +307,7 @@ public class YoutubeMixPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); - final File file = new File(RESOURCE_PATH + "channelMix"); - NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath())); + NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "channelMix")); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor( "https://www.youtube.com/watch?v=" + VIDEO_ID_OF_CHANNEL