Search in sources :

Example 41 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project openolat by klemens.

the class FeedManagerImplTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(coordinaterManagerMock.getCoordinator()).thenReturn(coordinaterMock);
    when(coordinaterMock.getSyncer()).thenReturn(syncerDummy);
    sut = new FeedManagerImpl(resourceManagerMock, fileResourceManagerMock, coordinaterManagerMock);
    feedDAOMock = mock(FeedDAO.class);
    ReflectionTestUtils.setField(sut, "feedDAO", feedDAOMock);
    ReflectionTestUtils.setField(sut, "itemDAO", itemDAOMock);
    ReflectionTestUtils.setField(sut, "feedFileStorage", feedFileStorageMock);
    ReflectionTestUtils.setField(sut, "externalFeedFetcher", feedFetcherMock);
    ReflectionTestUtils.setField(sut, "repositoryManager", repositoryManager);
    ReflectionTestUtils.setField(sut, "notificationsManager", notificationsManagerMock);
    when(internatFeedMock.getKey()).thenReturn(FEED_KEY);
    when(internatFeedMock.getResourceableTypeName()).thenReturn(RESOURCEABLE_TYPE_NAME);
    when(internatFeedMock.getResourceableId()).thenReturn(RESOURCABLE_ID);
    when(internatFeedMock.isInternal()).thenReturn(true);
    when(internalItemMock.getKey()).thenReturn(ITEM_KEY);
    when(internalItemMock.getFeed()).thenReturn(internatFeedMock);
    externalFeed = new FeedImpl(resourceDummy);
    externalFeed.setKey(FEED_KEY);
    externalFeed.setExternal(true);
    externalFeed.setExternalFeedUrl(EXTERNAL_URL_OLD);
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Before(org.junit.Before)

Example 42 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl 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();
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 43 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl 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;
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date) Feed(org.olat.modules.webFeed.Feed)

Example 44 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project openolat by klemens.

the class FeedDAO method createFeed.

public Feed createFeed(Feed feed) {
    if (feed == null)
        return null;
    FeedImpl feedImpl = (FeedImpl) feed;
    if (feedImpl.getCreationDate() == null) {
        feedImpl.setCreationDate(new Date());
    }
    if (feedImpl.getLastModified() == null) {
        feedImpl.setLastModified(feedImpl.getCreationDate());
    }
    dbInstance.getCurrentEntityManager().persist(feedImpl);
    return feed;
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date)

Example 45 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedDAOTest method createFeed_feed_keepDates.

@Test
public void createFeed_feed_keepDates() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    Feed tempFeed = new FeedImpl(resource);
    Date created = new GregorianCalendar(2000, 1, 1).getTime();
    tempFeed.setCreationDate(created);
    Date modified = new GregorianCalendar(2000, 2, 2).getTime();
    tempFeed.setLastModified(modified);
    Feed feed = feedDao.createFeed(tempFeed);
    dbInstance.commitAndCloseSession();
    // check values
    assertThat(feed.getCreationDate()).isCloseTo(created, 1000);
    assertThat(feed.getLastModified()).isCloseTo(modified, 1000);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) OLATResource(org.olat.resource.OLATResource) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

FeedImpl (org.olat.modules.webFeed.model.FeedImpl)82 Feed (org.olat.modules.webFeed.Feed)76 Test (org.junit.Test)74 BlogFileResource (org.olat.fileresource.types.BlogFileResource)58 Item (org.olat.modules.webFeed.Item)38 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)22 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)8 Date (java.util.Date)6 OLATResource (org.olat.resource.OLATResource)4 Path (java.nio.file.Path)2 GregorianCalendar (java.util.GregorianCalendar)2 Before (org.junit.Before)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2