Search in sources :

Example 26 with FeedImpl

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

the class FeedFileStorgeTest method loadFeedFromXML_Path.

@Test
public void loadFeedFromXML_Path() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    String autor = "autor";
    feed.setAuthor(autor);
    sut.saveFeedAsXML(feed);
    Path feedDir = fileResourceManager.getFileResource(resource).toPath();
    Feed reloaded = FeedManager.getInstance().loadFeedFromXML(feedDir);
    assertThat(reloaded).isNotNull();
    assertThat(reloaded.getAuthor()).isEqualTo(autor);
    fileResourceManager.deleteFileResource(resource);
}
Also used : Path(java.nio.file.Path) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 27 with FeedImpl

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

the class FeedFileStorgeTest method saveFeedAsXML_overwrite.

@Test
public void saveFeedAsXML_overwrite() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    feed.setAuthor("initialAuthor");
    sut.saveFeedAsXML(feed);
    feed.setAuthor("secondAuthor");
    sut.saveFeedAsXML(feed);
    // check if there is one file in the feed container
    assertThat(sut.getOrCreateFeedContainer(feed).getItems().size()).isEqualTo(1);
    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 28 with FeedImpl

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

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_create.

@Test
public void getOrCreateItemMediaContainer_create() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("guid");
    VFSContainer itemMediaContainer = sut.getOrCreateItemMediaContainer(item);
    assertThat(itemMediaContainer).isNotNull();
    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)

Example 29 with FeedImpl

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

the class FeedFileStorgeTest method saveItemAsXML_overwrite.

@Test
public void saveItemAsXML_overwrite() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("123");
    item.setAuthor("autor");
    sut.saveItemAsXML(item);
    item.setAuthor("secondAuthor");
    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 30 with FeedImpl

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

the class FeedFileStorgeTest method loadFeedFromXML_shortening_values.

@Test
public void loadFeedFromXML_shortening_values() {
    StringBuffer sb = new StringBuffer(5000);
    for (int i = 0; i < 5000; i++) {
        sb.append("A");
    }
    String stringWith5000Chars = sb.toString();
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    feed.setAuthor(stringWith5000Chars);
    feed.setDescription(stringWith5000Chars);
    feed.setTitle(stringWith5000Chars);
    feed.setExternalFeedUrl(stringWith5000Chars);
    feed.setExternalImageURL(stringWith5000Chars);
    sut.saveFeedAsXML(feed);
    Feed reloaded = sut.loadFeedFromXML(resource);
    assertThat(reloaded).isNotNull();
    assertThat(reloaded.getAuthor()).hasSize(255);
    assertThat(reloaded.getTitle()).hasSize(1024);
    assertThat(reloaded.getDescription()).hasSize(4000);
    assertThat(reloaded.getExternalFeedUrl()).isNull();
    assertThat(reloaded.getExternalImageURL()).isNull();
    assertThat(reloaded.getImageName()).isNull();
    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)

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