Search in sources :

Example 96 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method deleteItemContainer_not_existing.

@Test
public void deleteItemContainer_not_existing() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item1 = new ItemImpl(feed);
    item1.setGuid("guid 1");
    Item item2 = new ItemImpl(feed);
    item2.setGuid("guid 2");
    sut.getOrCreateItemContainer(item2);
    sut.deleteItemContainer(item1);
    // check if there is only one item container left
    assertThat(sut.getOrCreateFeedItemsContainer(feed).getItems().size()).isEqualTo(1);
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 97 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method loadItemByGuid_notExisting.

@Test
public void loadItemByGuid_notExisting() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // load item for a non existing guid
    Item item = itemDao.loadItemByGuid(feed.getKey(), "guid-no");
    // the item should be null
    assertThat(item).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 98 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method loadPublishedItems_Feed.

@Test
public void loadPublishedItems_Feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create three items
    int numberOfItems = 4;
    for (int i = 0; i < numberOfItems; i++) {
        Item item = new ItemImpl(feed);
        // Every 2nd Item has a publish date in the past
        if (i % 2 == 0) {
            Date date = Date.from(LocalDate.of(2000, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant());
            item.setPublishDate(date);
        }
        itemDao.createItem(feed, item);
    }
    dbInstance.commitAndCloseSession();
    List<Item> items = itemDao.loadPublishedItems(feed);
    // check if two items of the feed are loaded
    assertThat(items.size()).isEqualTo(2);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) LocalDate(java.time.LocalDate) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 99 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method removeItem.

@Test
public void removeItem() {
    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();
    // delete one item
    int numberOfDeletedItems = itemDao.removeItem(item2);
    dbInstance.commitAndCloseSession();
    // one item should be deleted
    assertThat(numberOfDeletedItems).isEqualTo(1);
    // check if one item is deleted and the two other items are still in
    // the database
    assertThat(itemDao.loadItem(item1.getKey())).isNotNull();
    assertThat(itemDao.loadItem(item2.getKey())).isNull();
    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 100 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method createItem_Feed_Null.

@Test
public void createItem_Feed_Null() {
    Item tempItem = new ItemImpl(null);
    Item item = itemDao.createItem(null, tempItem);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(item).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) Test(org.junit.Test)

Aggregations

Item (org.olat.modules.webFeed.Item)142 Test (org.junit.Test)98 Feed (org.olat.modules.webFeed.Feed)98 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)64 OLATResource (org.olat.resource.OLATResource)44 BlogFileResource (org.olat.fileresource.types.BlogFileResource)38 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)38 VFSContainer (org.olat.core.util.vfs.VFSContainer)26 Date (java.util.Date)16 VFSItem (org.olat.core.util.vfs.VFSItem)14 ArrayList (java.util.ArrayList)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)6 LocalDate (java.time.LocalDate)6 RSSFeed (org.olat.modules.webFeed.RSSFeed)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 OlatDocument (org.olat.search.model.OlatDocument)6 SyndContent (com.rometools.rome.feed.synd.SyndContent)4 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)4