From a065d3fc338371d1e5f0782bb99a847cc5a9ea93 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sat, 23 Mar 2024 18:06:02 +0100 Subject: Remove check for updated attributes, just update them (#7018) --- .../de/danoeh/antennapod/core/feed/FeedTest.java | 82 ++++------------------ .../antennapod/core/util/FeedItemUtilTest.java | 2 +- 2 files changed, 15 insertions(+), 69 deletions(-) (limited to 'core/src/test/java/de') 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 c256fea11..078f29ad7 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 @@ -8,9 +8,7 @@ import de.danoeh.antennapod.model.feed.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; +import static org.junit.Assert.assertThrows; public class FeedTest { @@ -24,92 +22,40 @@ public class FeedTest { } @Test - public void testCompareWithOther_feedImageDownloadUrlChanged() throws Exception { - setNewFeedImageDownloadUrl(); - feedHasChanged(); - } - - @Test - public void testCompareWithOther_sameFeedImage() throws Exception { - changedFeed.setImageUrl(FeedMother.IMAGE_URL); - feedHasNotChanged(); - } - - @Test - public void testCompareWithOther_feedImageRemoved() throws Exception { - feedImageRemoved(); - feedHasNotChanged(); - } - - @Test - public void testUpdateFromOther_feedImageDownloadUrlChanged() throws Exception { - setNewFeedImageDownloadUrl(); + public void testUpdateFromOther_feedImageDownloadUrlChanged() { + changedFeed.setImageUrl("http://example.com/new_picture"); original.updateFromOther(changedFeed); - feedImageWasUpdated(); + assertEquals(original.getImageUrl(), changedFeed.getImageUrl()); } @Test - public void testUpdateFromOther_feedImageRemoved() throws Exception { - feedImageRemoved(); + public void testUpdateFromOther_feedImageRemoved() { + changedFeed.setImageUrl(null); original.updateFromOther(changedFeed); - feedImageWasNotUpdated(); + assertEquals(anyFeed().getImageUrl(), original.getImageUrl()); } @Test - public void testUpdateFromOther_feedImageAdded() throws Exception { - feedHadNoImage(); - setNewFeedImageDownloadUrl(); + public void testUpdateFromOther_feedImageAdded() { + original.setImageUrl(null); + changedFeed.setImageUrl("http://example.com/new_picture"); original.updateFromOther(changedFeed); - feedImageWasUpdated(); + assertEquals(original.getImageUrl(), changedFeed.getImageUrl()); } @Test - public void testSetSortOrder_OnlyIntraFeedSortAllowed() throws Exception { + public void testSetSortOrder_OnlyIntraFeedSortAllowed() { 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 - } + assertThrows(IllegalArgumentException.class, () -> original.setSortOrder(sortOrder)); } } } @Test - public void testSetSortOrder_NullAllowed() throws Exception { + public void testSetSortOrder_NullAllowed() { original.setSortOrder(null); // should be okay } - - private void feedHasNotChanged() { - assertFalse(original.compareWithOther(changedFeed)); - } - - private void feedHadNoImage() { - original.setImageUrl(null); - } - - private void setNewFeedImageDownloadUrl() { - changedFeed.setImageUrl("http://example.com/new_picture"); - } - - private void feedHasChanged() { - assertTrue(original.compareWithOther(changedFeed)); - } - - private void feedImageRemoved() { - changedFeed.setImageUrl(null); - } - - private void feedImageWasUpdated() { - assertEquals(original.getImageUrl(), changedFeed.getImageUrl()); - } - - private void feedImageWasNotUpdated() { - assertEquals(anyFeed().getImageUrl(), original.getImageUrl()); - } - } \ No newline at end of file diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java index 6bc3c09a2..df9617ab4 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java @@ -94,7 +94,7 @@ public class FeedItemUtilTest { } private static FeedItem createFeedItem(String feedLink, String itemLink) { - Feed feed = new Feed(); + Feed feed = new Feed("http://example.com/feed", null); feed.setLink(feedLink); FeedItem feedItem = new FeedItem(); feedItem.setLink(itemLink); -- cgit v1.2.3