Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ protected void registerChannelTags() {
* Register channel attributes for mapping to channel object fields
*/
protected void registerChannelAttributes() {
channelAttributes.computeIfAbsent("/feed", k -> new HashMap<>()).put("lang", Channel::setLanguage);
channelAttributes.computeIfAbsent("link", k -> new HashMap<>()).put("href", Channel::setLink);
channelAttributes.computeIfAbsent("category", k -> new HashMap<>()).putIfAbsent("term", Channel::addCategory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void rssScb() throws IOException {
assertNotNull(channel);
assertThat(channel.getTitle(), is("Statistiska centralbyrån - Statistiknyheter"));
assertThat(channel.getDescription(), is("Statistiknyheter via RSS"));
assertThat(channel.getLanguage(), isEmpty());
assertThat(channel.getLanguage(), isPresentAndIs("sv-SE"));
assertThat(channel.getLink().toLowerCase(), is("http://www.scb.se/feed/statistiknyheter/"));
assertThat(channel.getCopyright(), isEmpty());
assertThat(channel.getGenerator(), isEmpty());
Expand Down Expand Up @@ -811,6 +811,14 @@ void multipleChanelDescriptionOnDifferentLevels() {
assertEquals("NYT > image description", item.getChannel().getImage().map(image -> image.getDescription().orElse("")).orElse(""));
}

@Test
void atomFeedWithLanguage() {
var list = new RssReader().read(fromFile("item-sort-test.xml"))
.collect(Collectors.toList());
assertEquals(10, list.size());
assertEquals("en", list.get(0).getChannel().getLanguage().orElse(""));
}

@Test
void atomFeedWithCategory() {
var list = new RssReader().read(fromFile("atom-feed-category.xml"))
Expand Down