Search in sources :

Example 1 with Feed

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

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)

Example 2 with Feed

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

the class FeedDAOTest method createFeed_feed.

@Test
public void createFeed_feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed tempFeed = new FeedImpl(resource);
    Feed feed = feedDao.createFeed(tempFeed);
    Assert.assertNotNull(feed);
    dbInstance.commitAndCloseSession();
    // check values
    Assert.assertNotNull(feed.getKey());
    Assert.assertNotNull(feed.getCreationDate());
    Assert.assertNotNull(feed.getLastModified());
    Assert.assertEquals(resource.getResourceableId(), feed.getResourceableId());
    Assert.assertEquals(resource.getResourceableTypeName(), feed.getResourceableTypeName());
}
Also used : OLATResource(org.olat.resource.OLATResource) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 3 with Feed

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

the class FeedDAOTest method copyFeed.

@Test
public void copyFeed() {
    OLATResource source = JunitTestHelper.createRandomResource();
    OLATResource target = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(source);
    dbInstance.commitAndCloseSession();
    Feed copy = feedDao.copyFeed(feed, target);
    dbInstance.commitAndCloseSession();
    assertThat(copy.getKey()).isNotEqualTo(feed.getKey());
    assertThat(copy.getResourceableId()).isNotEqualTo(feed.getResourceableId());
    assertThat(copy.getCreationDate()).isCloseTo(feed.getCreationDate(), 1000);
    assertThat(copy.getLastModified()).isCloseTo(feed.getLastModified(), 1000);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 4 with Feed

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

the class FeedDAOTest method updateFeed_null.

@Test
public void updateFeed_null() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    // create and save a feed
    feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // update null
    Feed updated = feedDao.updateFeed(null);
    // check values
    Assert.assertNull(updated);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 5 with Feed

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

the class FeedDAOTest method createFeed_ores.

@Test
public void createFeed_ores() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    Assert.assertNotNull(feed);
    dbInstance.commitAndCloseSession();
    // check values
    Assert.assertNotNull(feed.getKey());
    Assert.assertNotNull(feed.getCreationDate());
    Assert.assertNotNull(feed.getLastModified());
    Assert.assertEquals(resource.getResourceableId(), feed.getResourceableId());
    Assert.assertEquals(resource.getResourceableTypeName(), feed.getResourceableTypeName());
}
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