Search in sources :

Example 71 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class DbReaderTest method testGetQueueIdList.

@Test
public void testGetQueueIdList() {
    final int numItems = 10;
    List<FeedItem> queue = saveQueue(numItems);
    LongList ids = DBReader.getQueueIDList();
    assertNotNull(ids);
    assertEquals(ids.size(), queue.size());
    for (int i = 0; i < queue.size(); i++) {
        assertTrue(ids.get(i) != 0);
        assertEquals(ids.get(i), queue.get(i).getId());
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) LongList(de.danoeh.antennapod.core.util.LongList) Test(org.junit.Test)

Example 72 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class DbReaderTest method testGetItemByGuid.

@Test
public void testGetItemByGuid() {
    List<Feed> feeds = saveFeedlist(1, 1, true);
    FeedItem item1 = feeds.get(0).getItems().get(0);
    FeedItem feedItemByGuid = DBReader.getFeedItemByGuidOrEpisodeUrl(item1.getItemIdentifier(), item1.getMedia().getDownload_url());
    assertEquals(item1.getItemIdentifier(), feedItemByGuid.getItemIdentifier());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Feed(de.danoeh.antennapod.model.feed.Feed) Test(org.junit.Test)

Example 73 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class ExceptFavoriteCleanupAlgorithmTest method testPerformAutoCleanupSavesFavorited.

@Test
public void testPerformAutoCleanupSavesFavorited() throws IOException {
    Feed feed = new Feed("url", null, "title");
    List<FeedItem> items = new ArrayList<>();
    feed.setItems(items);
    List<File> files = new ArrayList<>();
    populateItems(numberOfItems, feed, items, files, FeedItem.UNPLAYED, false, true);
    DBTasks.performAutoCleanup(context);
    for (int i = 0; i < files.size(); i++) {
        assertTrue("Favorite episodes should should not be deleted", files.get(i).exists());
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ArrayList(java.util.ArrayList) File(java.io.File) Feed(de.danoeh.antennapod.model.feed.Feed) Test(org.junit.Test)

Example 74 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class ExceptFavoriteCleanupAlgorithmTest method testPerformAutoCleanupHandleUnplayed.

@Test
public void testPerformAutoCleanupHandleUnplayed() throws IOException {
    Feed feed = new Feed("url", null, "title");
    List<FeedItem> items = new ArrayList<>();
    feed.setItems(items);
    List<File> files = new ArrayList<>();
    populateItems(numberOfItems, feed, items, files, FeedItem.UNPLAYED, false, false);
    DBTasks.performAutoCleanup(context);
    for (int i = 0; i < files.size(); i++) {
        if (i < EPISODE_CACHE_SIZE) {
            assertTrue("Only enough items should be deleted", files.get(i).exists());
        } else {
            assertFalse("Expected episode to be deleted", files.get(i).exists());
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ArrayList(java.util.ArrayList) File(java.io.File) Feed(de.danoeh.antennapod.model.feed.Feed) Test(org.junit.Test)

Example 75 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class ItemEnqueuePositionCalculatorTest method createFeedItem.

static FeedItem createFeedItem(long id) {
    FeedItem item = new FeedItem(id, "Item" + id, "ItemId" + id, "url", new Date(), FeedItem.PLAYED, FeedMother.anyFeed());
    FeedMedia media = new FeedMedia(item, "http://download.url.net/" + id, 1234567, "audio/mpeg");
    media.setId(item.getId());
    item.setMedia(media);
    return item;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Date(java.util.Date)

Aggregations

FeedItem (de.danoeh.antennapod.model.feed.FeedItem)178 Feed (de.danoeh.antennapod.model.feed.Feed)74 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)48 Date (java.util.Date)47 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)46 File (java.io.File)26 Cursor (android.database.Cursor)20 NonNull (androidx.annotation.NonNull)15 Nullable (androidx.annotation.Nullable)11 Subscribe (org.greenrobot.eventbus.Subscribe)9 Intent (android.content.Intent)7 FeedFilter (de.danoeh.antennapod.model.feed.FeedFilter)7 View (android.view.View)6 LongList (de.danoeh.antennapod.core.util.LongList)6 SQLException (android.database.SQLException)5 Playable (de.danoeh.antennapod.model.playback.Playable)5 EpisodeAction (de.danoeh.antennapod.net.sync.model.EpisodeAction)5 ExecutionException (java.util.concurrent.ExecutionException)5 FeedItemPubdateComparator (de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator)4