From 9c895ef15a19b840a227a605814f94d787e5b508 Mon Sep 17 00:00:00 2001 From: orionlee Date: Thu, 24 Oct 2019 12:17:31 -0700 Subject: [PATCH] Test to ensure Feed only accepts INTRA_FEED sort order --- .../danoeh/antennapod/core/feed/FeedTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/test/java/de/danoeh/antennapod/core/feed/FeedTest.java b/core/src/test/java/de/danoeh/antennapod/core/feed/FeedTest.java index 4717041f4..88b342850 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/feed/FeedTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/feed/FeedTest.java @@ -3,10 +3,13 @@ package de.danoeh.antennapod.core.feed; import org.junit.Before; import org.junit.Test; +import de.danoeh.antennapod.core.util.SortOrder; + import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class FeedTest { @@ -59,6 +62,27 @@ public class FeedTest { feedImageWasUpdated(); } + @Test + public void testSetSortOrder_OnlyIntraFeedSortAllowed() throws Exception { + for (SortOrder sortOrder : SortOrder.values()) { + if (sortOrder.scope == SortOrder.Scope.INTRA_FEED) { + original.setSortOrder(sortOrder); // should be okay + } else { + try { + original.setSortOrder(sortOrder); + fail("SortOrder " + sortOrder + " should not be allowed on a feed"); + } catch (IllegalArgumentException iae) { + // expected exception + } + } + } + } + + @Test + public void testSetSortOrder_NullAllowed() throws Exception { + original.setSortOrder(null); // should be okay + } + private void feedHasNotChanged() { assertFalse(original.compareWithOther(changedFeed)); }