diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-04-05 19:20:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 19:20:27 +0200 |
commit | 92ab575b150ab49ca85e0ac994558142e49c9e68 (patch) | |
tree | 422dcd76895a4ba06ed02723ff61351435c0fe49 /model/src/test/java/de/danoeh/antennapod | |
parent | 2143ab135182434911d4554a8ef08115eaa0d2d0 (diff) | |
download | AntennaPod-92ab575b150ab49ca85e0ac994558142e49c9e68.zip |
Delete core module (#7060)
Diffstat (limited to 'model/src/test/java/de/danoeh/antennapod')
-rw-r--r-- | model/src/test/java/de/danoeh/antennapod/model/feed/FeedItemFallbackLinkTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/model/src/test/java/de/danoeh/antennapod/model/feed/FeedItemFallbackLinkTest.java b/model/src/test/java/de/danoeh/antennapod/model/feed/FeedItemFallbackLinkTest.java new file mode 100644 index 000000000..c0ea222e4 --- /dev/null +++ b/model/src/test/java/de/danoeh/antennapod/model/feed/FeedItemFallbackLinkTest.java @@ -0,0 +1,59 @@ +package de.danoeh.antennapod.model.feed; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class FeedItemFallbackLinkTest { + private static final String FEED_LINK = "http://example.com"; + private static final String ITEM_LINK = "http://example.com/feedItem1"; + + private final String msg; + private final String feedLink; + private final String itemLink; + private final String expected; + + @Parameters + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][]{ + {"average", FEED_LINK, ITEM_LINK, ITEM_LINK}, + {"null item link - fallback to feed", FEED_LINK, null, FEED_LINK}, + {"empty item link - same as null", FEED_LINK, "", FEED_LINK}, + {"blank item link - same as null", FEED_LINK, " ", FEED_LINK}, + {"fallback, but feed link is null too", null, null, null}, + {"fallback - but empty feed link - same as null", "", null, null}, + {"fallback - but blank feed link - same as null", " ", null, null} + }); + } + + public FeedItemFallbackLinkTest(String msg, String feedLink, String itemLink, String expected) { + this.msg = msg; + this.feedLink = feedLink; + this.itemLink = itemLink; + this.expected = expected; + } + + @Test + public void testLinkWithFallback() { + String actual = createFeedItem(feedLink, itemLink).getLinkWithFallback(); + assertEquals(msg, expected, actual); + } + + private static FeedItem createFeedItem(String feedLink, String itemLink) { + Feed feed = new Feed("http://example.com/feed", null); + feed.setLink(feedLink); + FeedItem feedItem = new FeedItem(); + feedItem.setLink(itemLink); + feedItem.setFeed(feed); + feed.setItems(Collections.singletonList(feedItem)); + return feedItem; + } +} |