Search in sources :

Example 56 with ItemImpl

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

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_Guid_empty.

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

Example 57 with ItemImpl

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

the class FeedFileStorgeTest method loadItemsFromXML_shortening.

@Test
public void loadItemsFromXML_shortening() {
    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);
    Item item = new ItemImpl(feed);
    String guid1 = "guid 1";
    item.setGuid(guid1);
    item.setAuthor(stringWith5000Chars);
    item.setExternalLink(stringWith5000Chars);
    item.setTitle(stringWith5000Chars);
    sut.saveItemAsXML(item);
    List<Item> items = sut.loadItemsFromXML(feed);
    Item reloadedItem = items.get(0);
    assertThat(reloadedItem.getAuthor()).hasSize(255);
    assertThat(reloadedItem.getExternalLink()).isNull();
    assertThat(reloadedItem.getTitle()).hasSize(1024);
    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 58 with ItemImpl

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

the class FeedFileStorgeTest method deleteItemContainer.

@Test
public void deleteItemContainer() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item1 = new ItemImpl(feed);
    item1.setGuid("guid 1");
    sut.getOrCreateItemContainer(item1);
    Item item2 = new ItemImpl(feed);
    item2.setGuid("guid 2");
    sut.getOrCreateItemContainer(item2);
    sut.deleteItemContainer(item1);
    // check if there is only one item container left
    assertThat(sut.getOrCreateFeedItemsContainer(feed).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 59 with ItemImpl

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

the class FeedFileStorgeTest method deleteItemXML.

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

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

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_get.

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

Aggregations

ItemImpl (org.olat.modules.webFeed.model.ItemImpl)70 Item (org.olat.modules.webFeed.Item)64 Test (org.junit.Test)58 Feed (org.olat.modules.webFeed.Feed)52 BlogFileResource (org.olat.fileresource.types.BlogFileResource)36 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)20 OLATResource (org.olat.resource.OLATResource)16 Date (java.util.Date)10 LocalDate (java.time.LocalDate)4 SyndContent (com.rometools.rome.feed.synd.SyndContent)2 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)2 XStream (com.thoughtworks.xstream.XStream)2 GregorianCalendar (java.util.GregorianCalendar)2 Link (org.olat.core.gui.components.link.Link)2 Identity (org.olat.core.id.Identity)2 Filter (org.olat.core.util.filter.Filter)2