Search in sources :

Example 86 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class ItemDAOTest method removeItems_Feed_isNull.

@Test
public void removeItems_Feed_isNull() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create three items
    Item item1 = itemDao.createItem(feed);
    Item item2 = itemDao.createItem(feed);
    Item item3 = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    // remove should be handled properly
    int numberOfDeletedItems = itemDao.removeItems(null);
    dbInstance.commitAndCloseSession();
    // no item should be deleted
    assertThat(numberOfDeletedItems).isEqualTo(0);
    // check if still all items are in the database
    assertThat(itemDao.loadItem(item1.getKey())).isNotNull();
    assertThat(itemDao.loadItem(item2.getKey())).isNotNull();
    assertThat(itemDao.loadItem(item3.getKey())).isNotNull();
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 87 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class ItemDAOTest method loadItems_Feed.

@Test
public void loadItems_Feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create three items
    int numberOfItems = 3;
    for (int i = 0; i < numberOfItems; i++) {
        itemDao.createItem(feed);
    }
    dbInstance.commitAndCloseSession();
    List<Item> items = itemDao.loadItems(feed);
    // check if all three items of the feed are loaded
    assertThat(items.size()).isEqualTo(3);
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 88 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class RomeFeedFetcherTest method justifiyFeed_externalImageUrlIsNull.

@Test
public void justifiyFeed_externalImageUrlIsNull() {
    String urlOld = "http://example.com/image1.jpg";
    String urlNew = null;
    Feed feed = new FeedImpl(oresMock);
    feed.setExternalImageURL(urlOld);
    when(syndFeedMock.getImage()).thenReturn(syndImageMock);
    when(syndImageMock.getUrl()).thenReturn(urlNew);
    Feed justifiedFeed = sut.justifyFeed(feed, syndFeedMock);
    assertThat(justifiedFeed.getExternalImageURL()).isNull();
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 89 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class FeedDAO method createFeedForResourcable.

public Feed createFeedForResourcable(OLATResourceable ores) {
    if (ores == null)
        return null;
    Feed feed = new FeedImpl(ores);
    feed.setCreationDate(new Date());
    feed.setLastModified(feed.getCreationDate());
    dbInstance.getCurrentEntityManager().persist(feed);
    return feed;
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date) Feed(org.olat.modules.webFeed.Feed)

Example 90 with Feed

use of org.olat.modules.webFeed.Feed in project openolat by klemens.

the class FeedFileStorge method getOrCreateItemContainer.

/**
 * Get the container of an item.
 * The container is created if it does not exist.
 *
 * @param ores
 * @return the container or null
 */
public VFSContainer getOrCreateItemContainer(Item item) {
    VFSContainer itemContainer = null;
    if (item != null) {
        Feed feed = item.getFeed();
        String guid = item.getGuid();
        itemContainer = getOrCreateItemContainer(feed, guid);
    }
    return itemContainer;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) Feed(org.olat.modules.webFeed.Feed)

Aggregations

Feed (org.olat.modules.webFeed.Feed)216 Test (org.junit.Test)162 Item (org.olat.modules.webFeed.Item)98 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)76 OLATResource (org.olat.resource.OLATResource)72 BlogFileResource (org.olat.fileresource.types.BlogFileResource)60 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)52 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)28 RSSFeed (org.olat.modules.webFeed.RSSFeed)24 Date (java.util.Date)22 RepositoryEntry (org.olat.repository.RepositoryEntry)12 OLATResourceable (org.olat.core.id.OLATResourceable)8 Path (java.nio.file.Path)6 LocalDate (java.time.LocalDate)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 OlatDocument (org.olat.search.model.OlatDocument)6 IOException (java.io.IOException)4