Search in sources :

Example 51 with FeedItem

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

the class FeedItemTest method testShownotes.

/**
 * Checks if the shownotes equal TEXT_LONG, using the given `description` and `content:encoded`.
 *
 * @param description Description of the feed item
 * @param contentEncoded `content:encoded` of the feed item
 */
private void testShownotes(String description, String contentEncoded) {
    FeedItem item = new FeedItem();
    item.setDescriptionIfLonger(description);
    item.setDescriptionIfLonger(contentEncoded);
    assertEquals(TEXT_LONG, item.getDescription());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem)

Example 52 with FeedItem

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

the class FeedMediaTest method testDownloadMediaOfPlayedItem_unchangedItemState.

/**
 * Downloading a media from a played item (thus not new) should not change the item state.
 */
@Test
public void testDownloadMediaOfPlayedItem_unchangedItemState() {
    FeedItem item = mock(FeedItem.class);
    when(item.isNew()).thenReturn(false);
    when(item.isPlayed()).thenReturn(true);
    media.setItem(item);
    media.setDownloaded(true);
    verify(item, never()).setNew();
    verify(item, never()).setPlayed(true);
    verify(item, never()).setPlayed(false);
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Test(org.junit.Test)

Example 53 with FeedItem

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

the class RemoteMedia method equals.

@Override
public boolean equals(Object other) {
    if (other instanceof RemoteMedia) {
        RemoteMedia rm = (RemoteMedia) other;
        return TextUtils.equals(downloadUrl, rm.downloadUrl) && TextUtils.equals(feedUrl, rm.feedUrl) && TextUtils.equals(itemIdentifier, rm.itemIdentifier);
    }
    if (other instanceof FeedMedia) {
        FeedMedia fm = (FeedMedia) other;
        if (!TextUtils.equals(downloadUrl, fm.getStreamUrl())) {
            return false;
        }
        FeedItem fi = fm.getItem();
        if (fi == null || !TextUtils.equals(itemIdentifier, fi.getItemIdentifier())) {
            return false;
        }
        Feed feed = fi.getFeed();
        return feed != null && TextUtils.equals(feedUrl, feed.getDownload_url());
    }
    return false;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 54 with FeedItem

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

the class FeedItemUtilTest method testGetIds.

// Test the getIds() method
@Test
public void testGetIds() {
    List<FeedItem> feedItemsList = new ArrayList<FeedItem>(5);
    List<Integer> idList = new ArrayList<Integer>();
    idList.add(980);
    idList.add(324);
    idList.add(226);
    idList.add(164);
    idList.add(854);
    for (int i = 0; i < 5; i++) {
        FeedItem item = createFeedItem(feedLink, itemLink);
        item.setId(idList.get(i));
        feedItemsList.add(item);
    }
    long[] actual = FeedItemUtil.getIds(feedItemsList);
    // covers edge case for getIds() method
    List<FeedItem> emptyList = new ArrayList<FeedItem>();
    long[] testEmptyList = FeedItemUtil.getIds(emptyList);
    assertEquals(msg, 0, testEmptyList.length);
    assertEquals(msg, 980, actual[0]);
    assertEquals(msg, 324, actual[1]);
    assertEquals(msg, 226, actual[2]);
    assertEquals(msg, 164, actual[3]);
    assertEquals(msg, 854, actual[4]);
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 55 with FeedItem

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

the class FeedItemUtilTest method createFeedItem.

private static FeedItem createFeedItem(String feedLink, String itemLink) {
    Feed feed = new Feed();
    feed.setLink(feedLink);
    FeedItem feedItem = new FeedItem();
    feedItem.setLink(itemLink);
    feedItem.setFeed(feed);
    feed.setItems(Collections.singletonList(feedItem));
    return feedItem;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Feed(de.danoeh.antennapod.model.feed.Feed)

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