Make xml adapters compile

This commit is contained in:
Shinokuni 2021-08-17 21:45:16 +02:00
parent 767662df59
commit f6b9791bfd
7 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.atom
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import junit.framework.TestCase.assertEquals
import org.junit.Test
@ -12,7 +13,7 @@ class ATOMFeedAdapterTest {
fun normalCasesTest() {
val stream = TestUtils.loadResource("localfeed/atom/atom_feed.xml")
val feed = adapter.fromXml(stream)
val feed = adapter.fromXml(stream.konsumeXml())
assertEquals(feed.name, "Recent Commits to Readrops:develop")
assertEquals(feed.url, "https://github.com/readrops/Readrops/commits/develop.atom")

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.atom
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.exceptions.ParseException
@ -20,7 +21,7 @@ class ATOMItemsAdapterTest {
fun normalCasesTest() {
val stream = TestUtils.loadResource("localfeed/atom/atom_items.xml")
val items = adapter.fromXml(stream)
val items = adapter.fromXml(stream.konsumeXml())
val item = items[0]
assertEquals(items.size, 4)
@ -37,7 +38,7 @@ class ATOMItemsAdapterTest {
fun noDateTest() {
val stream = TestUtils.loadResource("localfeed/atom/atom_items_no_date.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertNotNull(item.pubDate)
}
@ -48,7 +49,7 @@ class ATOMItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("Item title is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
@Test
@ -58,7 +59,7 @@ class ATOMItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("Item link is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
}

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.rss1
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import junit.framework.Assert.assertEquals
import org.junit.Test
@ -12,7 +13,7 @@ class RSS1FeedAdapterTest {
fun normalCaseTest() {
val stream = TestUtils.loadResource("localfeed/rss1/rss1_feed.xml")
val feed = adapter.fromXml(stream)
val feed = adapter.fromXml(stream.konsumeXml())
assertEquals(feed.name, "Slashdot")
assertEquals(feed.url, "https://slashdot.org/")

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.rss1
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.exceptions.ParseException
@ -20,7 +21,7 @@ class RSS1ItemsAdapterTest {
fun normalCasesTest() {
val stream = TestUtils.loadResource("localfeed/rss1/rss1_feed.xml")
val items = adapter.fromXml(stream)
val items = adapter.fromXml(stream.konsumeXml())
val item = items.first()
assertEquals(items.size, 4)
@ -39,7 +40,7 @@ class RSS1ItemsAdapterTest {
fun specialCasesTest() {
val stream = TestUtils.loadResource("localfeed/rss1/rss1_items_special_cases.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertEquals(item.author, "msmash, creator 2, creator 3, creator 4, ...")
assertEquals(item.link, "https://news.slashdot.org/story/20/09/23/1420240/a-new-york-clock-" +
@ -50,7 +51,7 @@ class RSS1ItemsAdapterTest {
fun nullDateTest() {
val stream = TestUtils.loadResource("localfeed/rss1/rss1_items_no_date.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertNotNull(item.pubDate)
}
@ -61,7 +62,7 @@ class RSS1ItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("Item title is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
@Test
@ -71,6 +72,6 @@ class RSS1ItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("RSS1 link or about element is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
}

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.rss2
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import com.readrops.api.utils.exceptions.ParseException
import junit.framework.TestCase.assertEquals
@ -14,7 +15,7 @@ class RSS2FeedAdapterTest {
fun normalCasesTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_full_feed.xml")
val feed = adapter.fromXml(stream)
val feed = adapter.fromXml(stream.konsumeXml())
assertEquals(feed.name, "Hacker News")
assertEquals(feed.url, "https://news.ycombinator.com/feed/")
@ -26,6 +27,6 @@ class RSS2FeedAdapterTest {
@Test(expected = ParseException::class)
fun nullTitleTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_feed_special_cases.xml")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
}

View File

@ -1,5 +1,6 @@
package com.readrops.api.localfeed.rss2
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.exceptions.ParseException
@ -20,7 +21,7 @@ class RSS2ItemsAdapterTest {
fun normalCasesTest() {
val stream = TestUtils.loadResource("localfeed/rss_feed.xml")
val items = adapter.fromXml(stream)
val items = adapter.fromXml(stream.konsumeXml())
val item = items.first()
assertEquals(items.size, 7)
@ -35,7 +36,7 @@ class RSS2ItemsAdapterTest {
@Test
fun otherNamespacesTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_items_other_namespaces.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertEquals(item.guid, "guid")
assertEquals(item.author, "creator 1, creator 2, creator 3, creator 4")
@ -46,7 +47,7 @@ class RSS2ItemsAdapterTest {
@Test
fun noDateTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_items_no_date.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertNotNull(item.pubDate)
}
@ -58,7 +59,7 @@ class RSS2ItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("Item title is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
@Test
@ -68,13 +69,13 @@ class RSS2ItemsAdapterTest {
expectedException.expect(ParseException::class.java)
expectedException.expectMessage("Item link is required")
adapter.fromXml(stream)
adapter.fromXml(stream.konsumeXml())
}
@Test
fun enclosureTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_items_enclosure.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertEquals(item.imageLink, "https://image1.jpg")
}
@ -82,7 +83,7 @@ class RSS2ItemsAdapterTest {
@Test
fun mediaContentTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_items_media_content.xml")
val items = adapter.fromXml(stream)
val items = adapter.fromXml(stream.konsumeXml())
assertEquals(items.first().imageLink, "https://image1.jpg")
assertEquals(items[1].imageLink, "https://image2.jpg")
@ -91,7 +92,7 @@ class RSS2ItemsAdapterTest {
@Test
fun mediaGroupTest() {
val stream = TestUtils.loadResource("localfeed/rss2/rss_items_media_group.xml")
val item = adapter.fromXml(stream).first()
val item = adapter.fromXml(stream.konsumeXml()).first()
assertEquals(item.imageLink, "https://image1.jpg")
}

View File

@ -1,5 +1,6 @@
package com.readrops.api.services.nextcloudnews.adapters
import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.TestUtils
import org.junit.Assert.assertEquals
import org.junit.Test
@ -12,6 +13,6 @@ class NextNewsUserAdapterTest {
fun validXmlTest() {
val stream = TestUtils.loadResource("services/nextcloudnews/user.xml")
assertEquals(adapter.fromXml(stream), "Shinokuni")
assertEquals(adapter.fromXml(stream.konsumeXml()), "Shinokuni")
}
}