Search in sources :

Example 21 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method saveItemAsXML_new.

@Test
public void saveItemAsXML_new() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("123");
    item.setAuthor("autor");
    sut.saveItemAsXML(item);
    // check if there is one file in the item container
    assertThat(sut.getOrCreateItemContainer(item).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 22 with FeedImpl

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

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 23 with FeedImpl

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

the class FeedDAOTest method createFeed_feed_keepDates.

@Test
public void createFeed_feed_keepDates() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed tempFeed = new FeedImpl(resource);
    Date created = new GregorianCalendar(2000, 1, 1).getTime();
    tempFeed.setCreationDate(created);
    Date modified = new GregorianCalendar(2000, 2, 2).getTime();
    tempFeed.setLastModified(modified);
    Feed feed = feedDao.createFeed(tempFeed);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(feed.getCreationDate()).isCloseTo(created, 1000);
    assertThat(feed.getLastModified()).isCloseTo(modified, 1000);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) OLATResource(org.olat.resource.OLATResource) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 24 with FeedImpl

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

the class FeedFileStorgeTest method deleteFeedXML_not_existing.

@Test
public void deleteFeedXML_not_existing() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    feed.setAuthor("initialAuthor");
    sut.deleteFeedXML(feed);
    // check if there is no file in the feed container
    assertThat(sut.getOrCreateFeedContainer(feed).getItems().size()).isEqualTo(0);
    fileResourceManager.deleteFileResource(resource);
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 25 with FeedImpl

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

the class FeedFileStorgeTest method loadItemFromXML_not_existing.

@Test
public void loadItemFromXML_not_existing() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    String guid = "guid öüä";
    item.setGuid(guid);
    String autor = "autor";
    item.setAuthor(autor);
    VFSContainer itemContainer = sut.getOrCreateItemContainer(item);
    Item reloaded = sut.loadItemFromXML(itemContainer);
    assertThat(reloaded).isNull();
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

FeedImpl (org.olat.modules.webFeed.model.FeedImpl)82 Feed (org.olat.modules.webFeed.Feed)76 Test (org.junit.Test)74 BlogFileResource (org.olat.fileresource.types.BlogFileResource)58 Item (org.olat.modules.webFeed.Item)38 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)22 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)8 Date (java.util.Date)6 OLATResource (org.olat.resource.OLATResource)4 Path (java.nio.file.Path)2 GregorianCalendar (java.util.GregorianCalendar)2 Before (org.junit.Before)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2