From b35eaa4fa568ffd9de5ec8ae06d0cbec14ab11df Mon Sep 17 00:00:00 2001 From: Mengshi24 <58278376+Mengshi24@users.noreply.github.com> Date: Sat, 5 Jun 2021 09:40:26 -0700 Subject: [PATCH] Add a unit test under DbWriterTest.java (#5181) --- .../antennapod/core/storage/DbWriterTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java index 093c416d1..e38d4adb7 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java @@ -779,6 +779,34 @@ public class DbWriterTest { } } + @Test + public void testRemoveAllNewFlags() throws Exception { + final int numItems = 10; + Feed feed = new Feed("url", null, "title"); + feed.setItems(new ArrayList<>()); + for (int i = 0; i < numItems; i++) { + FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, + new Date(), FeedItem.NEW, feed); + feed.getItems().add(item); + } + + PodDBAdapter adapter = PodDBAdapter.getInstance(); + adapter.open(); + adapter.setCompleteFeed(feed); + adapter.close(); + + assertTrue(feed.getId() != 0); + for (FeedItem item : feed.getItems()) { + assertTrue(item.getId() != 0); + } + + DBWriter.removeAllNewFlags(); + List loadedItems = DBReader.getFeedItemList(feed); + for (FeedItem item : loadedItems) { + assertFalse(item.isNew()); + } + } + @Test public void testMarkAllItemsReadSameFeed() throws Exception { final int numItems = 10;