Search in sources :

Example 26 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method loadItems_Feed.

@Test
public void loadItems_Feed() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    // create three items
    int numberOfItems = 3;
    for (int i = 0; i < numberOfItems; i++) {
        itemDao.createItem(feed);
    }
    dbInstance.commitAndCloseSession();
    List<Item> items = itemDao.loadItems(feed);
    // check if all three items of the feed are loaded
    assertThat(items.size()).isEqualTo(3);
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 27 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

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 28 with Item

use of org.olat.modules.webFeed.Item 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 29 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method copyItem_Feed_Item_noLastModified.

@Test
public void copyItem_Feed_Item_noLastModified() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed feed = feedDao.createFeedForResourcable(resource);
    dbInstance.commitAndCloseSession();
    Item item = itemDao.createItem(feed);
    dbInstance.commitAndCloseSession();
    item.setLastModified(null);
    Item copy = itemDao.copyItem(feed, item);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(copy).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 30 with Item

use of org.olat.modules.webFeed.Item in project OpenOLAT by OpenOLAT.

the class ItemDAOTest method createItem_Null.

@Test
public void createItem_Null() {
    Item item = itemDao.createItem(null);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(item).isNull();
}
Also used : Item(org.olat.modules.webFeed.Item) 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