Skip to content

Commit 436ddde

Browse files
committed
Use assertThrows in YoutubeDashManifestCreatorTest
1 parent d64d7bb commit 436ddde

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeDashManifestCreatorTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
88
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
99
import org.schabi.newpipe.extractor.stream.Stream;
10+
import org.schabi.newpipe.extractor.stream.VideoStream;
1011
import org.w3c.dom.Document;
1112
import org.w3c.dom.Element;
1213
import org.w3c.dom.NodeList;
@@ -26,6 +27,7 @@
2627
import static org.junit.jupiter.api.Assertions.assertNotEquals;
2728
import static org.junit.jupiter.api.Assertions.assertNotNull;
2829
import static org.junit.jupiter.api.Assertions.assertNull;
30+
import static org.junit.jupiter.api.Assertions.assertThrows;
2931
import static org.junit.jupiter.api.Assertions.assertTrue;
3032
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
3133
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
@@ -96,14 +98,14 @@ void testProgressiveStreamsANewEraOfOpen() throws Exception {
9698
extractor.getVideoOnlyStreams());
9799
testStreams(DeliveryMethod.PROGRESSIVE_HTTP,
98100
extractor.getAudioStreams());
99-
try {
100-
testStreams(DeliveryMethod.PROGRESSIVE_HTTP,
101-
extractor.getVideoStreams());
102-
} catch (final Exception e) {
103-
assertEquals(YoutubeDashManifestCreator.YoutubeDashManifestCreationException.class,
104-
e.getClass(), "The exception thrown was not the one excepted: "
105-
+ e.getClass().getName()
106-
+ "was thrown instead of YoutubeDashManifestCreationException");
101+
// This exception should be always thrown, as we are not able to generate DASH
102+
// manifests of video formats with audio
103+
final List<VideoStream> videoStreams = extractor.getVideoStreams();
104+
if (!videoStreams.isEmpty()) {
105+
assertThrows(YoutubeDashManifestCreator.YoutubeDashManifestCreationException.class,
106+
() -> testStreams(DeliveryMethod.PROGRESSIVE_HTTP, videoStreams),
107+
"The exception thrown for the generation of DASH manifests for YouTube "
108+
+ "progressive video streams with audio was not the one excepted");
107109
}
108110
}
109111

@@ -145,7 +147,7 @@ private void testStreams(@Nonnull final DeliveryMethod deliveryMethodToTest,
145147
assertFalse(isBlank(dashManifest), "The DASH manifest is null or empty: "
146148
+ dashManifest);
147149
}
148-
i++;
150+
++i;
149151
}
150152
}
151153

0 commit comments

Comments
 (0)