Search in sources :

Example 46 with Item

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

the class ItemDAOTest method loadItemByGuid_Feed_null.

@Test
public void loadItemByGuid_Feed_null() {
    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(null, guid);
    // check values
    assertThat(item).isNull();
}
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 47 with Item

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

the class ItemDAOTest method createItem_Feed_Item.

@Test
public void createItem_Feed_Item() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item tempItem = new ItemImpl(feed);
    Item item = itemDao.createItem(feed, tempItem);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(item.getKey()).isNotNull();
    assertThat(item.getCreationDate()).isNotNull();
    assertThat(item.getLastModified()).isNotNull();
    assertThat(item.getFeed()).isEqualTo(feed);
}
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 48 with Item

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

the class ItemDAOTest method loadItem.

@Test
public void loadItem() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create an item
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    // reload the item from the database
    Item reloaded = itemDao.loadItem(item.getKey());
    // check values
    assertThat(reloaded.getKey()).isEqualTo(item.getKey());
    assertThat(reloaded.getFeed()).isEqualTo(feed);
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 49 with Item

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

the class ItemDAOTest method updateItem.

@Test
public void updateItem() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("user-1234");
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    // update the item
    item.setAuthor("author");
    item.setAuthorKey(1L);
    item.setContent("content");
    item.setDescription("description");
    item.setDraft(true);
    item.setExternalLink("https://example.com/");
    item.setGuid("guid-2");
    item.setHeight(3);
    item.setModifierKey(author.getKey());
    item.setPublishDate(new Date());
    item.setTitle("tile");
    item.setWidth(5);
    Enclosure enclosure = new EnclosureImpl();
    enclosure.setExternalUrl("http://exterla.url/abc.jpg");
    enclosure.setFileName("Filename.jpg");
    enclosure.setLength(9L);
    enclosure.setType("type");
    item.setEnclosure(enclosure);
    Item updated = itemDao.updateItem(item);
    // check values
    assertThat(updated.getAuthor()).isEqualTo(item.getAuthor());
    assertThat(updated.getAuthorKey()).isEqualTo(item.getAuthorKey());
    assertThat(updated.getContent()).isEqualTo(item.getContent());
    assertThat(updated.getDescription()).isEqualTo(item.getDescription());
    assertThat(updated.isDraft()).isEqualTo(item.isDraft());
    assertThat(updated.getExternalLink()).isEqualTo(item.getExternalLink());
    assertThat(updated.getGuid()).isEqualTo(item.getGuid());
    assertThat(updated.getHeight()).isEqualTo(item.getHeight());
    assertThat(updated.getModifierKey()).isEqualTo(item.getModifierKey());
    assertThat(updated.getPublishDate()).isEqualTo(item.getPublishDate());
    assertThat(updated.getTitle()).isEqualTo(item.getTitle());
    assertThat(updated.getWidth()).isEqualTo(item.getWidth());
    assertThat(updated.getEnclosure().getExternalUrl()).isEqualTo(item.getEnclosure().getExternalUrl());
    assertThat(updated.getEnclosure().getFileName()).isEqualTo(item.getEnclosure().getFileName());
    assertThat(updated.getEnclosure().getLength()).isEqualTo(item.getEnclosure().getLength());
    assertThat(updated.getEnclosure().getType()).isEqualTo(item.getEnclosure().getType());
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Enclosure(org.olat.modules.webFeed.Enclosure) EnclosureImpl(org.olat.modules.webFeed.model.EnclosureImpl) Identity(org.olat.core.id.Identity) Date(java.util.Date) LocalDate(java.time.LocalDate) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 50 with Item

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

the class ItemDAOTest method loadItemByGuid_notExisting.

@Test
public void loadItemByGuid_notExisting() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // load item for a non existing guid
    Item item = itemDao.loadItemByGuid(feed.getKey(), "guid-no");
    // the item should be null
    assertThat(item).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

Item (org.olat.modules.webFeed.Item)142 Test (org.junit.Test)98 Feed (org.olat.modules.webFeed.Feed)98 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)64 OLATResource (org.olat.resource.OLATResource)44 BlogFileResource (org.olat.fileresource.types.BlogFileResource)38 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)38 VFSContainer (org.olat.core.util.vfs.VFSContainer)26 Date (java.util.Date)16 VFSItem (org.olat.core.util.vfs.VFSItem)14 ArrayList (java.util.ArrayList)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)6 LocalDate (java.time.LocalDate)6 RSSFeed (org.olat.modules.webFeed.RSSFeed)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 OlatDocument (org.olat.search.model.OlatDocument)6 SyndContent (com.rometools.rome.feed.synd.SyndContent)4 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)4