use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class ItemDAOTest method loadItemByGuid_Feed_null.
@Test
public void loadItemByGuid_Feed_null() {
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(null, guid);
// check values
assertThat(item).isNull();
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class ItemDAOTest method createItem_Feed_Item.
@Test
public void createItem_Feed_Item() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
Item tempItem = new ItemImpl(feed);
Item item = itemDao.createItem(feed, tempItem);
dbInstance.commitAndCloseSession();
// check values
assertThat(item.getKey()).isNotNull();
assertThat(item.getCreationDate()).isNotNull();
assertThat(item.getLastModified()).isNotNull();
assertThat(item.getFeed()).isEqualTo(feed);
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
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.Item in project openolat by klemens.
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 klemens.
the class ItemDAOTest method loadItemByGuid_notExisting.
@Test
public void loadItemByGuid_notExisting() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
// load item for a non existing guid
Item item = itemDao.loadItemByGuid(feed.getKey(), "guid-no");
// the item should be null
assertThat(item).isNull();
}
Aggregations