Add a unit test under DbWriterTest.java (#5181)

This commit is contained in:
Mengshi24 2021-06-05 09:40:26 -07:00 committed by GitHub
parent 8bcbc7ae32
commit b35eaa4fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 0 deletions

View File

@ -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<FeedItem> loadedItems = DBReader.getFeedItemList(feed);
for (FeedItem item : loadedItems) {
assertFalse(item.isNew());
}
}
@Test
public void testMarkAllItemsReadSameFeed() throws Exception {
final int numItems = 10;