Search in sources :

Example 61 with ItemImpl

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

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_Feed_null.

@Test
public void getOrCreateItemMediaContainer_Feed_null() {
    Item item = new ItemImpl(null);
    item.setGuid("guid");
    VFSContainer itemMediaContainer = sut.getOrCreateItemMediaContainer(item);
    assertThat(itemMediaContainer).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) Test(org.junit.Test)

Example 62 with ItemImpl

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

the class FeedFileStorgeTest method getOrCreateItemContainer_create.

@Test
public void getOrCreateItemContainer_create() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("guid");
    VFSContainer itemContainer = sut.getOrCreateItemContainer(item);
    assertThat(itemContainer).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 63 with ItemImpl

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

the class ItemDAOTest method loadItemByGuid_guidTwoTimes.

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

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

the class ItemDAOTest method loadPublishedItems_Feed.

@Test
public void loadPublishedItems_Feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create three items
    int numberOfItems = 4;
    for (int i = 0; i < numberOfItems; i++) {
        Item item = new ItemImpl(feed);
        // Every 2nd Item has a publish date in the past
        if (i % 2 == 0) {
            Date date = Date.from(LocalDate.of(2000, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant());
            item.setPublishDate(date);
        }
        itemDao.createItem(feed, item);
    }
    dbInstance.commitAndCloseSession();
    List<Item> items = itemDao.loadPublishedItems(feed);
    // check if two items of the feed are loaded
    assertThat(items.size()).isEqualTo(2);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) LocalDate(java.time.LocalDate) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 65 with ItemImpl

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

the class ItemDAOTest method loadItemByGuid.

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

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