Search in sources :

Example 1 with Enclosure

use of org.olat.modules.webFeed.Enclosure in project OpenOLAT by OpenOLAT.

the class RomeFeedFetcherTest method convertEnclosures_emptyList.

@Test
public void convertEnclosures_emptyList() {
    List<SyndEnclosure> enclosures = new ArrayList<>();
    Enclosure enclosure = sut.convertEnclosures(enclosures);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) ArrayList(java.util.ArrayList) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 2 with Enclosure

use of org.olat.modules.webFeed.Enclosure in project OpenOLAT by OpenOLAT.

the class RomeFeedFetcherTest method convertEnclosures_Url_null.

@Test
public void convertEnclosures_Url_null() {
    when(syndEnclosureMock.getUrl()).thenReturn(null);
    List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
    Enclosure enclosure = sut.convertEnclosures(enclosures);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 3 with Enclosure

use of org.olat.modules.webFeed.Enclosure in project OpenOLAT by OpenOLAT.

the class RomeFeedFetcherTest method convertEnclosures_null.

@Test
public void convertEnclosures_null() {
    Enclosure enclosure = sut.convertEnclosures(null);
    assertThat(enclosure).isNull();
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 4 with Enclosure

use of org.olat.modules.webFeed.Enclosure in project OpenOLAT by OpenOLAT.

the class RomeFeedFetcherTest method convertEnclosures.

@Test
public void convertEnclosures() {
    Long length = 1l;
    when(syndEnclosureMock.getLength()).thenReturn(length);
    String type = "type";
    when(syndEnclosureMock.getType()).thenReturn(type);
    String url = "url";
    when(syndEnclosureMock.getUrl()).thenReturn(url);
    List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
    Enclosure enclosure = sut.convertEnclosures(enclosures);
    assertThat(enclosure.getExternalUrl()).isEqualTo(url);
    assertThat(enclosure.getLength()).isEqualTo(length);
    assertThat(enclosure.getType()).isEqualTo(type);
}
Also used : SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) SyndEnclosure(com.rometools.rome.feed.synd.SyndEnclosure) Enclosure(org.olat.modules.webFeed.Enclosure) Test(org.junit.Test)

Example 5 with Enclosure

use of org.olat.modules.webFeed.Enclosure in project OpenOLAT by OpenOLAT.

the class FeedFileStorge method loadItemMedia.

/**
 * Load the media file of the item.
 *
 * @param item
 * @return
 */
public File loadItemMedia(Item item) {
    File file = null;
    Enclosure enclosure = item.getEnclosure();
    VFSContainer mediaDir = getOrCreateItemMediaContainer(item);
    if (mediaDir != null && enclosure != null) {
        VFSLeaf mediaFile = (VFSLeaf) mediaDir.resolve(enclosure.getFileName());
        if (mediaFile != null && mediaFile instanceof LocalFileImpl) {
            file = ((LocalFileImpl) mediaFile).getBasefile();
        }
    }
    return file;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) Enclosure(org.olat.modules.webFeed.Enclosure) File(java.io.File)

Aggregations

Enclosure (org.olat.modules.webFeed.Enclosure)20 SyndEnclosure (com.rometools.rome.feed.synd.SyndEnclosure)10 Test (org.junit.Test)10 EnclosureImpl (org.olat.modules.webFeed.model.EnclosureImpl)6 Date (java.util.Date)4 Feed (org.olat.modules.webFeed.Feed)4 Item (org.olat.modules.webFeed.Item)4 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)2 File (java.io.File)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 Identity (org.olat.core.id.Identity)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 RSSFeed (org.olat.modules.webFeed.RSSFeed)2 OLATResource (org.olat.resource.OLATResource)2