From 963350d1dd686ba2730f443075a15be050a19050 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 20 Sep 2020 19:00:49 +0200 Subject: [PATCH] Prepare files for the addition of RSS1 adapters --- .../RSSFeedAdapterTest.kt => rss2/RSS2FeedAdapterTest.kt} | 6 +++--- .../RSS2ItemsAdapterTest.kt} | 7 +++---- .../main/java/com/readrops/api/localfeed/XmlAdapter.kt | 8 ++++---- .../{rss/RSSFeedAdapter.kt => rss2/RSS2FeedAdapter.kt} | 4 ++-- .../{rss/RSSItemsAdapter.kt => rss2/RSS2ItemsAdapter.kt} | 4 ++-- .../java/com/readrops/api/localfeed/XmlAdapterTest.kt | 8 ++++---- 6 files changed, 18 insertions(+), 19 deletions(-) rename api/src/androidTest/java/com/readrops/api/localfeed/{rss/RSSFeedAdapterTest.kt => rss2/RSS2FeedAdapterTest.kt} (90%) rename api/src/androidTest/java/com/readrops/api/localfeed/{rss/RSSItemsAdapterTest.kt => rss2/RSS2ItemsAdapterTest.kt} (94%) rename api/src/main/java/com/readrops/api/localfeed/{rss/RSSFeedAdapter.kt => rss2/RSS2FeedAdapter.kt} (95%) rename api/src/main/java/com/readrops/api/localfeed/{rss/RSSItemsAdapter.kt => rss2/RSS2ItemsAdapter.kt} (97%) diff --git a/api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSFeedAdapterTest.kt b/api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapterTest.kt similarity index 90% rename from api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSFeedAdapterTest.kt rename to api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapterTest.kt index 79fbcafb..343cdae7 100644 --- a/api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSFeedAdapterTest.kt +++ b/api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapterTest.kt @@ -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() { diff --git a/api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSItemsAdapterTest.kt b/api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapterTest.kt similarity index 94% rename from api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSItemsAdapterTest.kt rename to api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapterTest.kt index 992a2cdb..b5d75e08 100644 --- a/api/src/androidTest/java/com/readrops/api/localfeed/rss/RSSItemsAdapterTest.kt +++ b/api/src/androidTest/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapterTest.kt @@ -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() { diff --git a/api/src/main/java/com/readrops/api/localfeed/XmlAdapter.kt b/api/src/main/java/com/readrops/api/localfeed/XmlAdapter.kt index bbc05bda..8f21a9e5 100644 --- a/api/src/main/java/com/readrops/api/localfeed/XmlAdapter.kt +++ b/api/src/main/java/com/readrops/api/localfeed/XmlAdapter.kt @@ -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 { companion object { fun xmlFeedAdapterFactory(type: LocalRSSHelper.RSSType): XmlAdapter { 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 { fun xmlItemsAdapterFactory(type: LocalRSSHelper.RSSType): XmlAdapter> { return when (type) { - LocalRSSHelper.RSSType.RSS_2 -> RSSItemsAdapter() + LocalRSSHelper.RSSType.RSS_2 -> RSS2ItemsAdapter() LocalRSSHelper.RSSType.ATOM -> ATOMItemsAdapter() else -> throw IllegalArgumentException("Unknown RSS type : $type") } diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSFeedAdapter.kt b/api/src/main/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapter.kt similarity index 95% rename from api/src/main/java/com/readrops/api/localfeed/rss/RSSFeedAdapter.kt rename to api/src/main/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapter.kt index 35f805a0..2751a428 100644 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSFeedAdapter.kt +++ b/api/src/main/java/com/readrops/api/localfeed/rss2/RSS2FeedAdapter.kt @@ -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 { +class RSS2FeedAdapter : XmlAdapter { override fun fromXml(inputStream: InputStream): Feed { val konsume = inputStream.konsumeXml() diff --git a/api/src/main/java/com/readrops/api/localfeed/rss/RSSItemsAdapter.kt b/api/src/main/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapter.kt similarity index 97% rename from api/src/main/java/com/readrops/api/localfeed/rss/RSSItemsAdapter.kt rename to api/src/main/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapter.kt index 5f074af3..fde85f49 100644 --- a/api/src/main/java/com/readrops/api/localfeed/rss/RSSItemsAdapter.kt +++ b/api/src/main/java/com/readrops/api/localfeed/rss2/RSS2ItemsAdapter.kt @@ -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> { +class RSS2ItemsAdapter : XmlAdapter> { override fun fromXml(inputStream: InputStream): List { val konsume = inputStream.konsumeXml() diff --git a/api/src/test/java/com/readrops/api/localfeed/XmlAdapterTest.kt b/api/src/test/java/com/readrops/api/localfeed/XmlAdapterTest.kt index 5da0b20c..23d74683 100644 --- a/api/src/test/java/com/readrops/api/localfeed/XmlAdapterTest.kt +++ b/api/src/test/java/com/readrops/api/localfeed/XmlAdapterTest.kt @@ -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) }