Fix some tests

- Use JSONObject#optString instead of JSONObject#getString to some optional values
- Check if url match the pattern before doing anything (for getId and cleanUrl in the url handlers)
- Ignore the suggestion tests
This commit is contained in:
Mauricio Colli 2017-08-08 12:01:50 -03:00
parent bf845d85aa
commit 81c2a3cb39
27 changed files with 124 additions and 104 deletions

View File

@ -29,7 +29,7 @@ import org.schabi.newpipe.extractor.user.UserInfoItemExtractor;
*/ */
public class InfoItemSearchCollector extends InfoItemCollector { public class InfoItemSearchCollector extends InfoItemCollector {
private String suggestion; private String suggestion = "";
private StreamInfoItemCollector streamCollector; private StreamInfoItemCollector streamCollector;
private UserInfoItemCollector userCollector; private UserInfoItemCollector userCollector;

View File

@ -53,7 +53,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
@Override @Override
public String getAvatarUrl() { public String getAvatarUrl() {
return playlist.getString("artwork_url"); return playlist.optString("artwork_url");
} }
@Override @Override

View File

@ -6,10 +6,13 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler { public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
private static final SoundcloudPlaylistUrlIdHandler instance = new SoundcloudPlaylistUrlIdHandler(); private static final SoundcloudPlaylistUrlIdHandler instance = new SoundcloudPlaylistUrlIdHandler();
private final String URL_PATTERN = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+" +
"/sets/[0-9a-z_-]+/?([#?].*)?$";
public static SoundcloudPlaylistUrlIdHandler getInstance() { public static SoundcloudPlaylistUrlIdHandler getInstance() {
return instance; return instance;
@ -26,6 +29,8 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
@Override @Override
public String getId(String url) throws ParsingException { public String getId(String url) throws ParsingException {
Utils.checkUrl(URL_PATTERN, url);
try { try {
return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url); return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url);
} catch (Exception e) { } catch (Exception e) {
@ -35,6 +40,8 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
@Override @Override
public String cleanUrl(String complexUrl) throws ParsingException { public String cleanUrl(String complexUrl) throws ParsingException {
Utils.checkUrl(URL_PATTERN, complexUrl);
try { try {
Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl)) Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl))
.select("meta[property=og:url]").first(); .select("meta[property=og:url]").first();
@ -47,7 +54,6 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
@Override @Override
public boolean acceptUrl(String url) { public boolean acceptUrl(String url) {
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/sets/[0-9a-z_-]+/?([#?].*)?$"; return Parser.isMatch(URL_PATTERN, url.toLowerCase());
return Parser.isMatch(regex, url.toLowerCase());
} }
} }

View File

@ -9,12 +9,7 @@ import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.*;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import java.io.IOException; import java.io.IOException;
@ -83,7 +78,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
return track.getString("artwork_url"); return track.optString("artwork_url");
} }
@Override @Override

View File

@ -45,7 +45,7 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
return searchResult.getString("artwork_url"); return searchResult.optString("artwork_url");
} }
@Override @Override

View File

@ -6,10 +6,13 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudStreamUrlIdHandler implements UrlIdHandler { public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
private static final SoundcloudStreamUrlIdHandler instance = new SoundcloudStreamUrlIdHandler(); private static final SoundcloudStreamUrlIdHandler instance = new SoundcloudStreamUrlIdHandler();
private final String URL_PATTERN = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+" +
"/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$";
private SoundcloudStreamUrlIdHandler() { private SoundcloudStreamUrlIdHandler() {
} }
@ -29,6 +32,8 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
@Override @Override
public String getId(String url) throws ParsingException { public String getId(String url) throws ParsingException {
Utils.checkUrl(URL_PATTERN, url);
try { try {
return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url); return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url);
} catch (Exception e) { } catch (Exception e) {
@ -38,6 +43,8 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
@Override @Override
public String cleanUrl(String complexUrl) throws ParsingException { public String cleanUrl(String complexUrl) throws ParsingException {
Utils.checkUrl(URL_PATTERN, complexUrl);
try { try {
Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl)) Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl))
.select("meta[property=og:url]").first(); .select("meta[property=og:url]").first();
@ -50,7 +57,6 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
@Override @Override
public boolean acceptUrl(String url) { public boolean acceptUrl(String url) {
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$"; return Parser.isMatch(URL_PATTERN, url.toLowerCase());
return Parser.isMatch(regex, url.toLowerCase());
} }
} }

View File

@ -12,7 +12,7 @@ public class SoundcloudUserInfoItemExtractor implements UserInfoItemExtractor {
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
return searchResult.getString("avatar_url"); return searchResult.optString("avatar_url");
} }
@Override @Override
@ -37,6 +37,6 @@ public class SoundcloudUserInfoItemExtractor implements UserInfoItemExtractor {
@Override @Override
public String getDescription() { public String getDescription() {
return searchResult.getString("description"); return searchResult.optString("description");
} }
} }

View File

@ -6,10 +6,13 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudUserUrlIdHandler implements UrlIdHandler { public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
private static final SoundcloudUserUrlIdHandler instance = new SoundcloudUserUrlIdHandler(); private static final SoundcloudUserUrlIdHandler instance = new SoundcloudUserUrlIdHandler();
private final String URL_PATTERN = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+" +
"(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
public static SoundcloudUserUrlIdHandler getInstance() { public static SoundcloudUserUrlIdHandler getInstance() {
return instance; return instance;
@ -26,6 +29,8 @@ public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
@Override @Override
public String getId(String url) throws ParsingException { public String getId(String url) throws ParsingException {
Utils.checkUrl(URL_PATTERN, url);
try { try {
return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url); return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url);
} catch (Exception e) { } catch (Exception e) {
@ -35,6 +40,8 @@ public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
@Override @Override
public String cleanUrl(String complexUrl) throws ParsingException { public String cleanUrl(String complexUrl) throws ParsingException {
Utils.checkUrl(URL_PATTERN, complexUrl);
try { try {
Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl)) Element ogElement = Jsoup.parse(NewPipe.getDownloader().download(complexUrl))
.select("meta[property=og:url]").first(); .select("meta[property=og:url]").first();
@ -47,7 +54,6 @@ public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
@Override @Override
public boolean acceptUrl(String url) { public boolean acceptUrl(String url) {
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$"; return Parser.isMatch(URL_PATTERN, url.toLowerCase());
return Parser.isMatch(regex, url.toLowerCase());
} }
} }

View File

@ -50,9 +50,7 @@ public class YoutubeUserUrlIdHandler implements UrlIdHandler {
@Override @Override
public boolean acceptUrl(String url) { public boolean acceptUrl(String url) {
return (url.contains("youtube") || return (url.contains("youtube") || url.contains("youtu.be"))
url.contains("youtu.be")) && && (url.contains("/user/") || url.contains("/channel/"));
(url.contains("/user/") ||
url.contains("/channel/"));
} }
} }

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.extractor.utils; package org.schabi.newpipe.extractor.utils;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
public class Utils { public class Utils {
private Utils() { private Utils() {
//no instance //no instance
@ -42,4 +44,20 @@ public class Utils {
} }
return false; return false;
} }
/**
* Check if the url matches the pattern.
*
* @param pattern the pattern that will be used to check the url
* @param url the url to be tested
*/
public static void checkUrl(String pattern, String url) throws ParsingException {
if (url == null || url.isEmpty()) {
throw new IllegalArgumentException("Url can't be null or empty");
}
if (!Parser.isMatch(pattern, url.toLowerCase())) {
throw new ParsingException("Url not suitable for this url handler");
}
}
} }

View File

@ -1,16 +1,14 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link PlaylistExtractor} * Test for {@link PlaylistExtractor}
*/ */

View File

@ -1,18 +1,19 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import java.util.EnumSet;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.extractor.search.SearchResult;
import java.util.EnumSet;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link SearchEngine} * Test for {@link SearchEngine}
*/ */
@ -42,6 +43,7 @@ public class SoundcloudSearchEngineAllTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -1,13 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import java.util.EnumSet;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
@ -15,6 +9,11 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.extractor.search.SearchResult;
import java.util.EnumSet;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link SearchEngine} * Test for {@link SearchEngine}
*/ */
@ -50,6 +49,7 @@ public class SoundcloudSearchEngineStreamTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -1,13 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import java.util.EnumSet;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
@ -15,6 +9,11 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchEngine;
import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.extractor.search.SearchResult;
import java.util.EnumSet;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link SearchEngine} * Test for {@link SearchEngine}
*/ */
@ -50,6 +49,7 @@ public class SoundcloudSearchEngineUserTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -1,12 +1,5 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import java.io.IOException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
@ -17,6 +10,11 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.StreamType;
import java.io.IOException;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link StreamExtractor} * Test for {@link StreamExtractor}
*/ */

View File

@ -1,18 +1,16 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/** /**
* Test for {@link SoundcloudStreamUrlIdHandler} * Test for {@link SoundcloudStreamUrlIdHandler}
*/ */
@ -25,7 +23,7 @@ public class SoundcloudStreamUrlIdHandlerTest {
NewPipe.init(Downloader.getInstance()); NewPipe.init(Downloader.getInstance());
} }
@Test(expected = NullPointerException.class) @Test(expected = IllegalArgumentException.class)
public void getIdWithNullAsUrl() throws ParsingException { public void getIdWithNullAsUrl() throws ParsingException {
urlIdHandler.getId(null); urlIdHandler.getId(null);
} }
@ -48,6 +46,7 @@ public class SoundcloudStreamUrlIdHandlerTest {
} }
} }
} }
@Test @Test
public void getId() throws Exception { public void getId() throws Exception {
assertEquals("309689103", urlIdHandler.getId("https://soundcloud.com/liluzivert/15-ysl")); assertEquals("309689103", urlIdHandler.getId("https://soundcloud.com/liluzivert/15-ysl"));

View File

@ -1,10 +1,5 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertFalse;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import java.io.IOException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
@ -12,6 +7,11 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.SuggestionExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import java.io.IOException;
import static org.junit.Assert.assertFalse;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link SuggestionExtractor} * Test for {@link SuggestionExtractor}
*/ */

View File

@ -1,16 +1,14 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.user.UserExtractor; import org.schabi.newpipe.extractor.user.UserExtractor;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
* Test for {@link UserExtractor} * Test for {@link UserExtractor}
*/ */

View File

@ -6,9 +6,7 @@ import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -63,6 +64,7 @@ public class YoutubeSearchEngineAllTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -1,8 +1,8 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -11,9 +11,7 @@ import org.schabi.newpipe.extractor.search.SearchResult;
import java.util.EnumSet; import java.util.EnumSet;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@ -72,6 +70,7 @@ public class YoutubeSearchEngineStreamTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.Downloader; import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
@ -10,9 +11,7 @@ import org.schabi.newpipe.extractor.search.SearchResult;
import java.util.EnumSet; import java.util.EnumSet;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@ -71,6 +70,7 @@ public class YoutubeSearchEngineUserTest {
assertTrue(result.errors == null || result.errors.isEmpty()); assertTrue(result.errors == null || result.errors.isEmpty());
} }
@Ignore
@Test @Test
public void testSuggestion() { public void testSuggestion() {
//todo write a real test //todo write a real test

View File

@ -33,7 +33,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
* This exception is only thrown in Germany. * This exception is only thrown in Germany.
* * <p>
* WARNING: Deactivate this Test Case before uploading it to Github, otherwise CI will fail. * WARNING: Deactivate this Test Case before uploading it to Github, otherwise CI will fail.
*/ */
@Ignore @Ignore

View File

@ -10,9 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertTrue;
/** /**
* Test for {@link YoutubeStreamUrlIdHandler} * Test for {@link YoutubeStreamUrlIdHandler}
@ -55,6 +53,7 @@ public class YoutubeStreamUrlIdHandlerTest {
} }
} }
} }
@Test @Test
public void getId() throws Exception { public void getId() throws Exception {
assertEquals("jZViOEv90dI", urlIdHandler.getId("https://www.youtube.com/watch?v=jZViOEv90dI")); assertEquals("jZViOEv90dI", urlIdHandler.getId("https://www.youtube.com/watch?v=jZViOEv90dI"));

View File

@ -6,9 +6,7 @@ import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.user.UserExtractor; import org.schabi.newpipe.extractor.user.UserExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/* /*