forked from Archives/Athou_commafeed
providers can now return multiple urls
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.commafeed.backend.urlprovider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -8,41 +10,7 @@ class InPageReferenceFeedURLProviderTest {
|
||||
private final InPageReferenceFeedURLProvider provider = new InPageReferenceFeedURLProvider();
|
||||
|
||||
@Test
|
||||
void extractsAtomFeedURL() {
|
||||
String url = "http://example.com";
|
||||
String html = """
|
||||
<html>
|
||||
<head>
|
||||
<link type="application/atom+xml" href="/feed.atom">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>""";
|
||||
|
||||
String result = provider.get(url, html);
|
||||
|
||||
Assertions.assertEquals("http://example.com/feed.atom", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractsRSSFeedURL() {
|
||||
String url = "http://example.com";
|
||||
String html = """
|
||||
<html>
|
||||
<head>
|
||||
<link type="application/rss+xml" href="/feed.rss">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>""";
|
||||
|
||||
String result = provider.get(url, html);
|
||||
|
||||
Assertions.assertEquals("http://example.com/feed.rss", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void prefersAtomOverRSS() {
|
||||
void extractUrls() {
|
||||
String url = "http://example.com";
|
||||
String html = """
|
||||
<html>
|
||||
@@ -54,26 +22,22 @@ class InPageReferenceFeedURLProviderTest {
|
||||
</body>
|
||||
</html>""";
|
||||
|
||||
String result = provider.get(url, html);
|
||||
|
||||
Assertions.assertEquals("http://example.com/feed.atom", result);
|
||||
Assertions.assertIterableEquals(List.of("http://example.com/feed.atom", "http://example.com/feed.rss"), provider.get(url, html));
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsNullForNonHtmlContent() {
|
||||
void returnsEmptyListForNonHtmlContent() {
|
||||
String url = "http://example.com";
|
||||
String content = """
|
||||
String html = """
|
||||
<?xml version="1.0"?>
|
||||
<feed></feed>
|
||||
</xml>""";
|
||||
|
||||
String result = provider.get(url, content);
|
||||
|
||||
Assertions.assertNull(result);
|
||||
Assertions.assertTrue(provider.get(url, html).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsNullForHtmlWithoutFeedLinks() {
|
||||
void returnsEmptyListForHtmlWithoutFeedLinks() {
|
||||
String url = "http://example.com";
|
||||
String html = """
|
||||
<html>
|
||||
@@ -84,8 +48,6 @@ class InPageReferenceFeedURLProviderTest {
|
||||
</body>
|
||||
</html>""";
|
||||
|
||||
String result = provider.get(url, html);
|
||||
|
||||
Assertions.assertNull(result);
|
||||
Assertions.assertTrue(provider.get(url, html).isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.commafeed.backend.urlprovider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -9,14 +11,14 @@ class YoutubeFeedURLProviderTest {
|
||||
|
||||
@Test
|
||||
void matchesYoutubeChannelURL() {
|
||||
Assertions.assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=abc",
|
||||
Assertions.assertIterableEquals(List.of("https://www.youtube.com/feeds/videos.xml?channel_id=abc"),
|
||||
provider.get("https://www.youtube.com/channel/abc", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotmatchYoutubeChannelURL() {
|
||||
Assertions.assertNull(provider.get("https://www.anothersite.com/channel/abc", null));
|
||||
Assertions.assertNull(provider.get("https://www.youtube.com/user/abc", null));
|
||||
Assertions.assertTrue(provider.get("https://www.anothersite.com/channel/abc", null).isEmpty());
|
||||
Assertions.assertTrue(provider.get("https://www.youtube.com/user/abc", null).isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user