use of org.olat.modules.webFeed.Feed 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);
}
use of org.olat.modules.webFeed.Feed 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();
}
use of org.olat.modules.webFeed.Feed 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);
}
use of org.olat.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.modules.webFeed.Feed in project openolat by klemens.
the class FeedDAOTest method loadFeed_Long.
@Test
public void loadFeed_Long() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
Feed reloaded = feedDao.loadFeed(feed.getKey());
// check values
Assert.assertEquals(feed.getKey(), reloaded.getKey());
Assert.assertEquals(resource.getResourceableId(), reloaded.getResourceableId());
Assert.assertEquals(resource.getResourceableTypeName(), reloaded.getResourceableTypeName());
// It's ok when the date is about the same in the database.
Assert.assertTrue("Dates aren't close enough to each other!", (feed.getCreationDate().getTime() - reloaded.getCreationDate().getTime()) < 1000);
}
Aggregations