Use assertThrows in YoutubeDashManifestCreatorTest
This commit is contained in:
parent
d64d7bbd01
commit
436ddde29f
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
|
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
|
||||||
import org.schabi.newpipe.extractor.stream.Stream;
|
import org.schabi.newpipe.extractor.stream.Stream;
|
||||||
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
@ -26,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
|
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
|
||||||
|
@ -96,14 +98,14 @@ class YoutubeDashManifestCreatorTest {
|
||||||
extractor.getVideoOnlyStreams());
|
extractor.getVideoOnlyStreams());
|
||||||
testStreams(DeliveryMethod.PROGRESSIVE_HTTP,
|
testStreams(DeliveryMethod.PROGRESSIVE_HTTP,
|
||||||
extractor.getAudioStreams());
|
extractor.getAudioStreams());
|
||||||
try {
|
// This exception should be always thrown, as we are not able to generate DASH
|
||||||
testStreams(DeliveryMethod.PROGRESSIVE_HTTP,
|
// manifests of video formats with audio
|
||||||
extractor.getVideoStreams());
|
final List<VideoStream> videoStreams = extractor.getVideoStreams();
|
||||||
} catch (final Exception e) {
|
if (!videoStreams.isEmpty()) {
|
||||||
assertEquals(YoutubeDashManifestCreator.YoutubeDashManifestCreationException.class,
|
assertThrows(YoutubeDashManifestCreator.YoutubeDashManifestCreationException.class,
|
||||||
e.getClass(), "The exception thrown was not the one excepted: "
|
() -> testStreams(DeliveryMethod.PROGRESSIVE_HTTP, videoStreams),
|
||||||
+ e.getClass().getName()
|
"The exception thrown for the generation of DASH manifests for YouTube "
|
||||||
+ "was thrown instead of YoutubeDashManifestCreationException");
|
+ "progressive video streams with audio was not the one excepted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +147,7 @@ class YoutubeDashManifestCreatorTest {
|
||||||
assertFalse(isBlank(dashManifest), "The DASH manifest is null or empty: "
|
assertFalse(isBlank(dashManifest), "The DASH manifest is null or empty: "
|
||||||
+ dashManifest);
|
+ dashManifest);
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue