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