Search in sources :

Example 16 with ItemImpl

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

the class ItemDAOTest method createItem_Feed_Item_keepDates.

@Test
public void createItem_Feed_Item_keepDates() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item tempItem = new ItemImpl(feed);
    Date created = new GregorianCalendar(2000, 1, 1).getTime();
    tempItem.setCreationDate(created);
    Date modified = new GregorianCalendar(2000, 2, 2).getTime();
    tempItem.setLastModified(modified);
    Item item = itemDao.createItem(feed, tempItem);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(item.getCreationDate()).isCloseTo(created, 1000);
    assertThat(item.getLastModified()).isCloseTo(modified, 1000);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) GregorianCalendar(java.util.GregorianCalendar) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) LocalDate(java.time.LocalDate) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 17 with ItemImpl

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

the class ItemDAOTest method loadItemByGuid_without_feed.

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

use of org.olat.modules.webFeed.model.ItemImpl 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)

Example 19 with ItemImpl

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

the class FeedFileStorgeTest method getOrCreateItemContainer_Feed_null.

@Test
public void getOrCreateItemContainer_Feed_null() {
    Item item = new ItemImpl(null);
    item.setGuid("guid");
    VFSContainer itemContainer = sut.getOrCreateItemContainer(item);
    assertThat(itemContainer).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 20 with ItemImpl

use of org.olat.modules.webFeed.model.ItemImpl 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)

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