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();
}
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);
}
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();
}
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);
}
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();
}
Aggregations