Prepare files for the addition of RSS1 adapters

This commit is contained in:
Shinokuni 2020-09-20 19:00:49 +02:00
parent cb41f3c7ac
commit 963350d1dd
6 changed files with 18 additions and 19 deletions

View File

@ -1,4 +1,4 @@
package com.readrops.api.localfeed.rss
package com.readrops.api.localfeed.rss2
import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
@ -9,11 +9,11 @@ import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class RSSFeedAdapterTest {
class RSS2FeedAdapterTest {
private val context: Context = InstrumentationRegistry.getInstrumentation().context
private val adapter = RSSFeedAdapter()
private val adapter = RSS2FeedAdapter()
@Test
fun normalCasesTest() {

View File

@ -1,4 +1,4 @@
package com.readrops.api.localfeed.rss
package com.readrops.api.localfeed.rss2
import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
@ -6,17 +6,16 @@ import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException
import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertNotNull
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class RSSItemsAdapterTest {
class RSS2ItemsAdapterTest {
private val context: Context = InstrumentationRegistry.getInstrumentation().context
private val adapter = RSSItemsAdapter()
private val adapter = RSS2ItemsAdapter()
@Test
fun normalCasesTest() {

View File

@ -2,8 +2,8 @@ package com.readrops.api.localfeed
import com.readrops.api.localfeed.atom.ATOMFeedAdapter
import com.readrops.api.localfeed.atom.ATOMItemsAdapter
import com.readrops.api.localfeed.rss.RSSFeedAdapter
import com.readrops.api.localfeed.rss.RSSItemsAdapter
import com.readrops.api.localfeed.rss2.RSS2FeedAdapter
import com.readrops.api.localfeed.rss2.RSS2ItemsAdapter
import com.readrops.db.entities.Feed
import com.readrops.db.entities.Item
import java.io.InputStream
@ -16,7 +16,7 @@ interface XmlAdapter<T> {
companion object {
fun xmlFeedAdapterFactory(type: LocalRSSHelper.RSSType): XmlAdapter<Feed> {
return when (type) {
LocalRSSHelper.RSSType.RSS_2 -> RSSFeedAdapter()
LocalRSSHelper.RSSType.RSS_2 -> RSS2FeedAdapter()
LocalRSSHelper.RSSType.ATOM -> ATOMFeedAdapter()
else -> throw IllegalArgumentException("Unknown RSS type : $type")
}
@ -24,7 +24,7 @@ interface XmlAdapter<T> {
fun xmlItemsAdapterFactory(type: LocalRSSHelper.RSSType): XmlAdapter<List<Item>> {
return when (type) {
LocalRSSHelper.RSSType.RSS_2 -> RSSItemsAdapter()
LocalRSSHelper.RSSType.RSS_2 -> RSS2ItemsAdapter()
LocalRSSHelper.RSSType.ATOM -> ATOMItemsAdapter()
else -> throw IllegalArgumentException("Unknown RSS type : $type")
}

View File

@ -1,4 +1,4 @@
package com.readrops.api.localfeed.rss
package com.readrops.api.localfeed.rss2
import com.gitlab.mvysny.konsumexml.Names
import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
@ -11,7 +11,7 @@ import com.readrops.db.entities.Feed
import org.jsoup.Jsoup
import java.io.InputStream
class RSSFeedAdapter : XmlAdapter<Feed> {
class RSS2FeedAdapter : XmlAdapter<Feed> {
override fun fromXml(inputStream: InputStream): Feed {
val konsume = inputStream.konsumeXml()

View File

@ -1,4 +1,4 @@
package com.readrops.api.localfeed.rss
package com.readrops.api.localfeed.rss2
import com.gitlab.mvysny.konsumexml.*
import com.readrops.api.localfeed.XmlAdapter
@ -6,7 +6,7 @@ import com.readrops.api.utils.*
import com.readrops.db.entities.Item
import java.io.InputStream
class RSSItemsAdapter : XmlAdapter<List<Item>> {
class RSS2ItemsAdapter : XmlAdapter<List<Item>> {
override fun fromXml(inputStream: InputStream): List<Item> {
val konsume = inputStream.konsumeXml()

View File

@ -2,8 +2,8 @@ package com.readrops.api.localfeed
import com.readrops.api.localfeed.atom.ATOMFeedAdapter
import com.readrops.api.localfeed.atom.ATOMItemsAdapter
import com.readrops.api.localfeed.rss.RSSFeedAdapter
import com.readrops.api.localfeed.rss.RSSItemsAdapter
import com.readrops.api.localfeed.rss2.RSS2FeedAdapter
import com.readrops.api.localfeed.rss2.RSS2ItemsAdapter
import junit.framework.TestCase.assertTrue
import org.junit.Assert
import org.junit.Test
@ -12,7 +12,7 @@ class XmlAdapterTest {
@Test
fun xmlFeedAdapterFactoryTest() {
assertTrue(XmlAdapter.xmlFeedAdapterFactory(LocalRSSHelper.RSSType.RSS_2) is RSSFeedAdapter)
assertTrue(XmlAdapter.xmlFeedAdapterFactory(LocalRSSHelper.RSSType.RSS_2) is RSS2FeedAdapter)
assertTrue(XmlAdapter.xmlFeedAdapterFactory(LocalRSSHelper.RSSType.ATOM) is ATOMFeedAdapter)
Assert.assertThrows(IllegalArgumentException::class.java) { XmlAdapter.xmlFeedAdapterFactory(LocalRSSHelper.RSSType.UNKNOWN) }
@ -20,7 +20,7 @@ class XmlAdapterTest {
@Test
fun xmlItemsAdapterFactoryTest() {
assertTrue(XmlAdapter.xmlItemsAdapterFactory(LocalRSSHelper.RSSType.RSS_2) is RSSItemsAdapter)
assertTrue(XmlAdapter.xmlItemsAdapterFactory(LocalRSSHelper.RSSType.RSS_2) is RSS2ItemsAdapter)
assertTrue(XmlAdapter.xmlItemsAdapterFactory(LocalRSSHelper.RSSType.ATOM) is ATOMItemsAdapter)
Assert.assertThrows(IllegalArgumentException::class.java) { XmlAdapter.xmlItemsAdapterFactory(LocalRSSHelper.RSSType.UNKNOWN) }