11package org .schabi .newpipe .extractor .services .soundcloud ;
22
3- import org .hamcrest .CoreMatchers ;
43import org .junit .BeforeClass ;
54import org .junit .Test ;
65import org .schabi .newpipe .DownloaderTestImpl ;
109import org .schabi .newpipe .extractor .services .BasePlaylistExtractorTest ;
1110import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
1211
12+ import static org .hamcrest .CoreMatchers .*;
1313import static org .junit .Assert .*;
1414import static org .schabi .newpipe .extractor .ExtractorAsserts .assertIsSecureUrl ;
1515import static org .schabi .newpipe .extractor .ServiceList .SoundCloud ;
@@ -71,14 +71,6 @@ public void testRelatedItems() throws Exception {
7171 @ Test
7272 public void testMoreRelatedItems () throws Exception {
7373 defaultTestMoreItems (extractor );
74-
75- try {
76- defaultTestMoreItems (extractor );
77- } catch (Throwable ignored ) {
78- return ;
79- }
80-
81- fail ("This playlist doesn't have more items, it should throw an error" );
8274 }
8375
8476 /*//////////////////////////////////////////////////////////////////////////
@@ -100,7 +92,7 @@ public void testBannerUrl() {
10092 public void testUploaderUrl () {
10193 final String uploaderUrl = extractor .getUploaderUrl ();
10294 assertIsSecureUrl (uploaderUrl );
103- assertTrue (uploaderUrl , uploaderUrl . contains ("liluzivert" ));
95+ assertThat (uploaderUrl , containsString ("liluzivert" ));
10496 }
10597
10698 @ Test
@@ -115,7 +107,7 @@ public void testUploaderAvatarUrl() {
115107
116108 @ Test
117109 public void testStreamCount () {
118- assertTrue ("Error in the streams count" , extractor .getStreamCount () >= 10 );
110+ assertTrue ("Stream count does not fit: " + extractor . getStreamCount () , extractor .getStreamCount () >= 10 );
119111 }
120112 }
121113
@@ -192,7 +184,7 @@ public void testBannerUrl() {
192184 public void testUploaderUrl () {
193185 final String uploaderUrl = extractor .getUploaderUrl ();
194186 assertIsSecureUrl (uploaderUrl );
195- assertThat (uploaderUrl , CoreMatchers . containsString ("micky96" ));
187+ assertThat (uploaderUrl , containsString ("micky96" ));
196188 }
197189
198190 @ Test
@@ -207,7 +199,7 @@ public void testUploaderAvatarUrl() {
207199
208200 @ Test
209201 public void testStreamCount () {
210- assertTrue ("Error in the streams count" , extractor .getStreamCount () >= 10 );
202+ assertTrue ("Stream count does not fit: " + extractor . getStreamCount () , extractor .getStreamCount () >= 10 );
211203 }
212204 }
213205
@@ -228,17 +220,8 @@ public static void setUp() throws Exception {
228220
229221 @ Test
230222 public void testGetPageInNewExtractor () throws Exception {
231- final PlaylistExtractor newExtractor = SoundCloud .getPlaylistExtractor (extractor .getUrl ());
223+ PlaylistExtractor newExtractor = SoundCloud .getPlaylistExtractor (extractor .getUrl ());
232224 defaultTestGetPageInNewExtractor (extractor , newExtractor );
233- String page1 = newExtractor .getNextPageUrl ();
234- defaultTestMoreItems (newExtractor ); // there has to be another page
235- String page2 = newExtractor .getNextPageUrl ();
236- defaultTestMoreItems (newExtractor ); // and another one
237- String page3 = newExtractor .getNextPageUrl ();
238-
239- assertNotEquals ("Same pages" , page1 , page2 );
240- assertNotEquals ("Same pages" , page2 , page3 );
241- assertNotEquals ("Same pages" , page3 , page1 );
242225 }
243226
244227 /*//////////////////////////////////////////////////////////////////////////
@@ -326,4 +309,102 @@ public void testStreamCount() {
326309 assertTrue ("Stream count does not fit: " + extractor .getStreamCount (), extractor .getStreamCount () >= 370 );
327310 }
328311 }
312+
313+ public static class SmallPlaylist implements BasePlaylistExtractorTest {
314+ private static SoundcloudPlaylistExtractor extractor ;
315+
316+ @ BeforeClass
317+ public static void setUp () throws Exception {
318+ NewPipe .init (DownloaderTestImpl .getInstance ());
319+ extractor = (SoundcloudPlaylistExtractor ) SoundCloud
320+ .getPlaylistExtractor ("https://soundcloud.com/breezy-123/sets/empty-playlist?test=123" );
321+ extractor .fetchPage ();
322+ }
323+
324+ /*//////////////////////////////////////////////////////////////////////////
325+ // Extractor
326+ //////////////////////////////////////////////////////////////////////////*/
327+
328+ @ Test
329+ public void testServiceId () {
330+ assertEquals (SoundCloud .getServiceId (), extractor .getServiceId ());
331+ }
332+
333+ @ Test
334+ public void testName () {
335+ assertEquals ("EMPTY PLAYLIST" , extractor .getName ());
336+ }
337+
338+ @ Test
339+ public void testId () {
340+ assertEquals ("23483459" , extractor .getId ());
341+ }
342+
343+ @ Test
344+ public void testUrl () throws Exception {
345+ assertEquals ("https://soundcloud.com/breezy-123/sets/empty-playlist" , extractor .getUrl ());
346+ }
347+
348+ @ Test
349+ public void testOriginalUrl () throws Exception {
350+ assertEquals ("https://soundcloud.com/breezy-123/sets/empty-playlist?test=123" , extractor .getOriginalUrl ());
351+ }
352+
353+ /*//////////////////////////////////////////////////////////////////////////
354+ // ListExtractor
355+ //////////////////////////////////////////////////////////////////////////*/
356+
357+ @ Test
358+ public void testRelatedItems () throws Exception {
359+ defaultTestRelatedItems (extractor );
360+ }
361+
362+ @ Test
363+ public void testMoreRelatedItems () throws Exception {
364+ try {
365+ defaultTestMoreItems (extractor );
366+ } catch (Throwable ignored ) {
367+ return ;
368+ }
369+
370+ fail ("This playlist doesn't have more items, it should throw an error" );
371+ }
372+
373+ /*//////////////////////////////////////////////////////////////////////////
374+ // PlaylistExtractor
375+ //////////////////////////////////////////////////////////////////////////*/
376+
377+ @ Test
378+ public void testThumbnailUrl () {
379+ assertIsSecureUrl (extractor .getThumbnailUrl ());
380+ }
381+
382+ @ Test
383+ public void testBannerUrl () {
384+ // SoundCloud playlists do not have a banner
385+ assertNull (extractor .getBannerUrl ());
386+ }
387+
388+ @ Test
389+ public void testUploaderUrl () {
390+ final String uploaderUrl = extractor .getUploaderUrl ();
391+ assertIsSecureUrl (uploaderUrl );
392+ assertThat (uploaderUrl , containsString ("breezy-123" ));
393+ }
394+
395+ @ Test
396+ public void testUploaderName () {
397+ assertEquals ("breezy-123" , extractor .getUploaderName ());
398+ }
399+
400+ @ Test
401+ public void testUploaderAvatarUrl () {
402+ assertIsSecureUrl (extractor .getUploaderAvatarUrl ());
403+ }
404+
405+ @ Test
406+ public void testStreamCount () {
407+ assertEquals (2 , extractor .getStreamCount ());
408+ }
409+ }
329410}
0 commit comments