66import org .schabi .newpipe .extractor .ListExtractor ;
77import org .schabi .newpipe .extractor .NewPipe ;
88import org .schabi .newpipe .extractor .playlist .PlaylistExtractor ;
9+ import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
10+
11+ import java .util .List ;
912
1013import static org .junit .Assert .*;
14+ import static org .schabi .newpipe .extractor .ExtractorAsserts .assertEmptyErrors ;
1115import static org .schabi .newpipe .extractor .ServiceList .YouTube ;
1216
1317/**
14- * Test for {@link PlaylistExtractor }
18+ * Test for {@link YoutubePlaylistExtractor }
1519 */
16-
1720public class YoutubePlaylistExtractorTest {
18- private PlaylistExtractor extractor ;
21+ private YoutubePlaylistExtractor extractor ;
22+
23+ private static void assertNotEmpty (String message , String value ) {
24+ assertNotNull (message , value );
25+ assertFalse (message , value .isEmpty ());
26+ }
1927
2028 @ Before
2129 public void setUp () throws Exception {
2230 NewPipe .init (Downloader .getInstance ());
23- extractor = YouTube .getService ()
31+ extractor = ( YoutubePlaylistExtractor ) YouTube .getService ()
2432 .getPlaylistExtractor ("https://www.youtube.com/playlist?list=PL7XlqX4npddfrdpMCxBnNZXg2GFll7t5y" );
2533 }
2634
@@ -71,12 +79,22 @@ public void testGetStreamsCount() throws Exception {
7179
7280 @ Test
7381 public void testGetStreams () throws Exception {
74- assertTrue ("no streams are received" , !extractor .getStreams ().getItemList ().isEmpty ());
82+ List <StreamInfoItem > streams = extractor .getStreams ().getItemList ();
83+ assertFalse ("no streams are received" , streams .isEmpty ());
84+ assertTrue (streams .size () > 60 );
85+ assertFalse (streams .contains (null ));
86+ for (StreamInfoItem item : streams ) {
87+ assertEquals ("Service id doesn't match" , YouTube .getId (), item .getServiceId ());
88+ assertNotNull ("Stream type not set: " + item , item .getStreamType ());
89+ //assertNotEmpty("Upload date not set: " + item, item.getUploadDate());
90+ assertNotEmpty ("Uploader name not set: " + item , item .getUploaderName ());
91+ assertNotEmpty ("Uploader url not set: " + item , item .getUploaderUrl ());
92+ }
7593 }
7694
7795 @ Test
7896 public void testGetStreamsErrors () throws Exception {
79- assertTrue ("errors during stream list extraction" , extractor .getStreams ().getErrors (). isEmpty ());
97+ assertEmptyErrors ("errors during stream list extraction" , extractor .getStreams ().getErrors ());
8098 }
8199
82100 @ Test
@@ -92,7 +110,7 @@ public void testGetNextStreams() throws Exception {
92110 extractor .getStreams ();
93111 ListExtractor .NextItemsResult nextItemsResult = extractor .getNextStreams ();
94112 assertTrue ("extractor didn't have next streams" , !nextItemsResult .nextItemsList .isEmpty ());
95- assertTrue ("errors occurred during extraction of the next streams" , nextItemsResult .errors . isEmpty () );
113+ assertEmptyErrors ("errors occurred during extraction of the next streams" , nextItemsResult .errors );
96114 assertTrue ("extractor didn't have more streams after getNextStreams" , extractor .hasMoreStreams ());
97115 }
98116
0 commit comments