Use Locale.forLanguageTag() in tests

This commit is contained in:
Isira Seneviratne 2023-09-18 08:59:13 +05:30
parent 90aed06a63
commit 4bc8ae7812
2 changed files with 9 additions and 11 deletions

View File

@ -1,5 +1,10 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContainsImageUrlInImageCollection;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
@ -10,19 +15,13 @@ import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStream
import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.utils.LocaleCompat;
import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals; import javax.annotation.Nullable;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContainsImageUrlInImageCollection;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
/** /**
* Test {@link MediaCCCStreamExtractor} * Test {@link MediaCCCStreamExtractor}
@ -96,7 +95,7 @@ public class MediaCCCStreamExtractorTest {
super.testAudioStreams(); super.testAudioStreams();
final List<AudioStream> audioStreams = extractor.getAudioStreams(); final List<AudioStream> audioStreams = extractor.getAudioStreams();
assertEquals(2, audioStreams.size()); assertEquals(2, audioStreams.size());
final Locale expectedLocale = LocaleCompat.forLanguageTag("deu"); final Locale expectedLocale = Locale.forLanguageTag("deu");
assertTrue(audioStreams.stream().allMatch(audioStream -> assertTrue(audioStreams.stream().allMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), expectedLocale))); Objects.equals(audioStream.getAudioLocale(), expectedLocale)));
} }
@ -174,7 +173,7 @@ public class MediaCCCStreamExtractorTest {
super.testAudioStreams(); super.testAudioStreams();
final List<AudioStream> audioStreams = extractor.getAudioStreams(); final List<AudioStream> audioStreams = extractor.getAudioStreams();
assertEquals(2, audioStreams.size()); assertEquals(2, audioStreams.size());
final Locale expectedLocale = LocaleCompat.forLanguageTag("eng"); final Locale expectedLocale = Locale.forLanguageTag("eng");
assertTrue(audioStreams.stream().allMatch(audioStream -> assertTrue(audioStreams.stream().allMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), expectedLocale))); Objects.equals(audioStream.getAudioLocale(), expectedLocale)));
} }

View File

@ -50,7 +50,6 @@ import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamSegment; import org.schabi.newpipe.extractor.stream.StreamSegment;
import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.utils.LocaleCompat;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -560,7 +559,7 @@ public class YoutubeStreamExtractorDefaultTest {
.anyMatch(audioStream -> .anyMatch(audioStream ->
"English original".equals(audioStream.getAudioTrackName()))); "English original".equals(audioStream.getAudioTrackName())));
final Locale hindiLocale = LocaleCompat.forLanguageTag("hi"); final Locale hindiLocale = Locale.forLanguageTag("hi");
assertTrue(audioStreams.stream() assertTrue(audioStreams.stream()
.anyMatch(audioStream -> .anyMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), hindiLocale))); Objects.equals(audioStream.getAudioLocale(), hindiLocale)));