22
33import org .junit .jupiter .api .BeforeAll ;
44import org .junit .jupiter .api .Test ;
5+ import org .junit .jupiter .params .ParameterizedTest ;
6+ import org .junit .jupiter .params .provider .CsvSource ;
7+ import org .junit .jupiter .params .provider .ValueSource ;
58import org .schabi .newpipe .downloader .DownloaderTestImpl ;
69import org .schabi .newpipe .extractor .NewPipe ;
710import org .schabi .newpipe .extractor .exceptions .ParsingException ;
@@ -25,57 +28,54 @@ public static void setUp() throws Exception {
2528 }
2629
2730 @ Test
28- public void getIdWithNullAsUrl () {
31+ void getIdWithNullAsUrl () {
2932 assertThrows (IllegalArgumentException .class , () -> linkHandler .fromUrl (null ));
3033 }
3134
32- @ Test
33- public void getIdForInvalidUrls () {
34- List <String > invalidUrls = new ArrayList <>(50 );
35- invalidUrls .add ("https://soundcloud.com/liluzivert/t.e.s.t" );
36- invalidUrls .add ("https://soundcloud.com/liluzivert/tracks" );
37- invalidUrls .add ("https://soundcloud.com/" );
38- for (String invalidUrl : invalidUrls ) {
39- Throwable exception = null ;
40- try {
41- linkHandler .fromUrl (invalidUrl ).getId ();
42- } catch (ParsingException e ) {
43- exception = e ;
44- }
45- if (exception == null ) {
46- fail ("Expected ParsingException for url: " + invalidUrl );
47- }
48- }
35+ @ ParameterizedTest
36+ @ ValueSource (strings = {
37+ "https://soundcloud.com/liluzivert/t.e.s.t" ,
38+ "https://soundcloud.com/liluzivert/tracks" ,
39+ "https://soundcloud.com/"
40+ })
41+ void getIdForInvalidUrls (final String invalidUrl ) {
42+ assertThrows (ParsingException .class , () -> linkHandler .fromUrl (invalidUrl ).getId ());
4943 }
5044
51- @ Test
52- public void getId () throws Exception {
53- assertEquals ("309689103" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/15-ysl" ).getId ());
54- assertEquals ("309689082" , linkHandler .fromUrl ("https://www.soundcloud.com/liluzivert/15-luv-scars-ko" ).getId ());
55- assertEquals ("309689035" , linkHandler .fromUrl ("http://soundcloud.com/liluzivert/15-boring-shit" ).getId ());
56- assertEquals ("259273264" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/ps-qs-produced-by-don-cannon/" ).getId ());
57- assertEquals ("294488599" , linkHandler .fromUrl ("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats" ).getId ());
58- assertEquals ("294488438" , linkHandler .fromUrl ("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz" ).getId ());
59- assertEquals ("294488147" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69" ).getId ());
60- assertEquals ("294487876" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09" ).getId ());
61- assertEquals ("294487684" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9" ).getId ());
62- assertEquals ("294487428" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s" ).getId ());
63- assertEquals ("294487157" , linkHandler .fromUrl ("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s" ).getId ());
64- assertEquals ("44556776" , linkHandler .fromUrl ("https://soundcloud.com/kechuspider-sets-1/last-days" ).getId ());
45+ @ ParameterizedTest
46+ @ CsvSource (value = {
47+ "309689103,https://soundcloud.com/liluzivert/15-ysl" ,
48+ "309689082,https://www.soundcloud.com/liluzivert/15-luv-scars-ko" ,
49+ "309689035,http://soundcloud.com/liluzivert/15-boring-shit" ,
50+ "259273264,https://soundcloud.com/liluzivert/ps-qs-produced-by-don-cannon/" ,
51+ "294488599,http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats" ,
52+ "245710200,HtTpS://sOuNdClOuD.cOm/lIeuTeNaNt_rAe/bOtS-wAs-wOlLeN-wIr-tRinKeN" ,
53+ "294488147,https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69" ,
54+ "294487876,https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09" ,
55+ "294487684,https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9" ,
56+ "294487428,https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s" ,
57+ "294487157,https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s" ,
58+ "44556776,https://soundcloud.com/kechuspider-sets-1/last-days"
59+ })
60+ void getId (final String expectedId , final String url ) throws ParsingException {
61+ assertEquals (expectedId , linkHandler .fromUrl (url ).getId ());
6562 }
6663
6764
68- @ Test
69- public void testAcceptUrl () throws ParsingException {
70- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/15-ysl" ));
71- assertTrue (linkHandler .acceptUrl ("https://www.soundcloud.com/liluzivert/15-luv-scars-ko" ));
72- assertTrue (linkHandler .acceptUrl ("http://soundcloud.com/liluzivert/15-boring-shit" ));
73- assertTrue (linkHandler .acceptUrl ("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats" ));
74- assertTrue (linkHandler .acceptUrl ("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz" ));
75- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69" ));
76- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09" ));
77- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9" ));
78- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s" ));
79- assertTrue (linkHandler .acceptUrl ("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s" ));
65+ @ ParameterizedTest
66+ @ ValueSource (strings = {
67+ "https://soundcloud.com/liluzivert/15-ysl" ,
68+ "https://www.soundcloud.com/liluzivert/15-luv-scars-ko" ,
69+ "http://soundcloud.com/liluzivert/15-boring-shit" ,
70+ "http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats" ,
71+ "HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz" ,
72+ "https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69" ,
73+ "https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09" ,
74+ "https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9" ,
75+ "https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s" ,
76+ "https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s"
77+ })
78+ void testAcceptUrl (final String url ) throws ParsingException {
79+ assertTrue (linkHandler .acceptUrl (url ));
8080 }
8181}
0 commit comments