use of org.olat.modules.webFeed.Feed in project openolat by klemens.
the class ItemDAOTest method removeItems_Feed_isNull.
@Test
public void removeItems_Feed_isNull() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
// create three items
Item item1 = itemDao.createItem(feed);
Item item2 = itemDao.createItem(feed);
Item item3 = itemDao.createItem(feed);
dbInstance.commitAndCloseSession();
// remove should be handled properly
int numberOfDeletedItems = itemDao.removeItems(null);
dbInstance.commitAndCloseSession();
// no item should be deleted
assertThat(numberOfDeletedItems).isEqualTo(0);
// check if still all items are in the database
assertThat(itemDao.loadItem(item1.getKey())).isNotNull();
assertThat(itemDao.loadItem(item2.getKey())).isNotNull();
assertThat(itemDao.loadItem(item3.getKey())).isNotNull();
}
use of org.olat.modules.webFeed.Feed in project openolat by klemens.
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);
}
use of org.olat.modules.webFeed.Feed in project openolat by klemens.
the class RomeFeedFetcherTest method justifiyFeed_externalImageUrlIsNull.
@Test
public void justifiyFeed_externalImageUrlIsNull() {
String urlOld = "http://example.com/image1.jpg";
String urlNew = null;
Feed feed = new FeedImpl(oresMock);
feed.setExternalImageURL(urlOld);
when(syndFeedMock.getImage()).thenReturn(syndImageMock);
when(syndImageMock.getUrl()).thenReturn(urlNew);
Feed justifiedFeed = sut.justifyFeed(feed, syndFeedMock);
assertThat(justifiedFeed.getExternalImageURL()).isNull();
}
use of org.olat.modules.webFeed.Feed in project openolat by klemens.
the class FeedDAO method createFeedForResourcable.
public Feed createFeedForResourcable(OLATResourceable ores) {
if (ores == null)
return null;
Feed feed = new FeedImpl(ores);
feed.setCreationDate(new Date());
feed.setLastModified(feed.getCreationDate());
dbInstance.getCurrentEntityManager().persist(feed);
return feed;
}
use of org.olat.modules.webFeed.Feed in project openolat by klemens.
the class FeedFileStorge method getOrCreateItemContainer.
/**
* Get the container of an item.
* The container is created if it does not exist.
*
* @param ores
* @return the container or null
*/
public VFSContainer getOrCreateItemContainer(Item item) {
VFSContainer itemContainer = null;
if (item != null) {
Feed feed = item.getFeed();
String guid = item.getGuid();
itemContainer = getOrCreateItemContainer(feed, guid);
}
return itemContainer;
}
Aggregations