Search in sources :

Example 21 with Item

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

the class ItemDAOTest method copyItem_Feed_Item_null.

@Test
public void copyItem_Feed_Item_null() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item copy = itemDao.copyItem(feed, null);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(copy).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 22 with Item

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

the class ItemDAOTest method removeItems_Feed.

@Test
public void removeItems_Feed() {
    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 all items of the feed
    int numberOfDeletedItems = itemDao.removeItems(feed);
    dbInstance.commitAndCloseSession();
    // three item should be deleted
    assertThat(numberOfDeletedItems).isEqualTo(3);
    // check if items are deleted
    assertThat(itemDao.loadItem(item1.getKey())).isNull();
    assertThat(itemDao.loadItem(item2.getKey())).isNull();
    assertThat(itemDao.loadItem(item3.getKey())).isNull();
    // the feed should still exist
    assertThat(feedDao.loadFeed(resource)).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 23 with Item

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

the class ItemDAOTest method copyItem_Feed_Item.

@Test
public void copyItem_Feed_Item() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    Item copy = itemDao.copyItem(feed, item);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(copy.getKey()).isNotEqualTo(item.getKey());
    assertThat(copy.getCreationDate()).isCloseTo(item.getCreationDate(), 1000);
    assertThat(copy.getLastModified()).isCloseTo(item.getLastModified(), 1000);
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 24 with Item

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

the class ItemDAOTest method loadItemByGuid_Feed_null.

@Test
public void loadItemByGuid_Feed_null() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create an item
    String guid = "guid-123";
    Item tempItem = new ItemImpl(feed);
    tempItem.setGuid(guid);
    itemDao.createItem(feed, tempItem);
    dbInstance.commitAndCloseSession();
    // reload the item from the database
    Item item = itemDao.loadItemByGuid(null, guid);
    // check values
    assertThat(item).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 25 with Item

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

the class ItemDAOTest method updateItem_null.

@Test
public void updateItem_null() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item item = itemDao.createItem(null);
    dbInstance.commitAndCloseSession();
    Item updated = itemDao.updateItem(item);
    assertThat(updated).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) 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