Search in sources :

Example 46 with Feed

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

the class ItemDAOTest method createItem_Feed_Item_keepDates.

@Test
public void createItem_Feed_Item_keepDates() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item tempItem = new ItemImpl(feed);
    Date created = new GregorianCalendar(2000, 1, 1).getTime();
    tempItem.setCreationDate(created);
    Date modified = new GregorianCalendar(2000, 2, 2).getTime();
    tempItem.setLastModified(modified);
    Item item = itemDao.createItem(feed, tempItem);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(item.getCreationDate()).isCloseTo(created, 1000);
    assertThat(item.getLastModified()).isCloseTo(modified, 1000);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) GregorianCalendar(java.util.GregorianCalendar) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) LocalDate(java.time.LocalDate) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 47 with Feed

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

the class ItemDAOTest method copyItem_Feed_Item_noLastModified.

@Test
public void copyItem_Feed_Item_noLastModified() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    item.setLastModified(null);
    Item copy = itemDao.copyItem(feed, item);
    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 48 with Feed

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

the class ItemDAOTest method loadItemByGuid_without_feed.

@Test
public void loadItemByGuid_without_feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create an item
    String guid = "guid-123467890";
    Item tempItem = new ItemImpl(feed);
    tempItem.setGuid(guid);
    itemDao.createItem(feed, tempItem);
    dbInstance.commitAndCloseSession();
    // reload the item from the database
    Item item = itemDao.loadItemByGuid(guid);
    // check values
    assertThat(item).isNotNull();
    // clean up
    itemDao.removeItem(item);
}
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 49 with Feed

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

the class ItemDAOTest method loadItem.

@Test
public void loadItem() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create an item
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    // reload the item from the database
    Item reloaded = itemDao.loadItem(item.getKey());
    // check values
    assertThat(reloaded.getKey()).isEqualTo(item.getKey());
    assertThat(reloaded.getFeed()).isEqualTo(feed);
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 50 with Feed

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

the class FeedDAOTest method loadFeed_Long.

@Test
public void loadFeed_Long() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Feed reloaded = feedDao.loadFeed(feed.getKey());
    // check values
    Assert.assertEquals(feed.getKey(), reloaded.getKey());
    Assert.assertEquals(resource.getResourceableId(), reloaded.getResourceableId());
    Assert.assertEquals(resource.getResourceableTypeName(), reloaded.getResourceableTypeName());
    // It's ok when the date is about the same in the database.
    Assert.assertTrue("Dates aren't close enough to each other!", (feed.getCreationDate().getTime() - reloaded.getCreationDate().getTime()) < 1000);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

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