From 63a8891880a03e5e8bff3c026ec9dc82fcf86f29 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Thu, 2 Sep 2021 13:54:27 +0200 Subject: [PATCH] Fix tests --- .../localfeed/rss1/RSS1ItemsAdapterTest.kt | 4 ++-- .../com/readrops/api/opml/OPMLParserTest.kt | 24 +++++++++---------- .../main/java/com/readrops/db/dao/FeedDao.kt | 3 +++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/api/src/test/java/com/readrops/api/localfeed/rss1/RSS1ItemsAdapterTest.kt b/api/src/test/java/com/readrops/api/localfeed/rss1/RSS1ItemsAdapterTest.kt index 7efda78f..07bcf72f 100644 --- a/api/src/test/java/com/readrops/api/localfeed/rss1/RSS1ItemsAdapterTest.kt +++ b/api/src/test/java/com/readrops/api/localfeed/rss1/RSS1ItemsAdapterTest.kt @@ -25,9 +25,9 @@ class RSS1ItemsAdapterTest { assertEquals(items.size, 4) assertEquals(item.title, "Google Expands its Flutter Development Kit To Windows Apps") - assertEquals(item.link.trim(), "https://developers.slashdot.org/story/20/09/23/1616231/google-expands-" + + assertEquals(item.link!!.trim(), "https://developers.slashdot.org/story/20/09/23/1616231/google-expands-" + "its-flutter-development-kit-to-windows-apps?utm_source=rss1.0mainlinkanon&utm_medium=feed") - assertEquals(item.guid.trim(), "https://developers.slashdot.org/story/20/09/23/1616231/google-expands-" + + assertEquals(item.guid!!.trim(), "https://developers.slashdot.org/story/20/09/23/1616231/google-expands-" + "its-flutter-development-kit-to-windows-apps?utm_source=rss1.0mainlinkanon&utm_medium=feed") assertEquals(item.pubDate, DateUtils.parse("2020-09-23T16:15:00+00:00")) assertEquals(item.author, "msmash") diff --git a/api/src/test/java/com/readrops/api/opml/OPMLParserTest.kt b/api/src/test/java/com/readrops/api/opml/OPMLParserTest.kt index a28a8df7..32d3fd56 100644 --- a/api/src/test/java/com/readrops/api/opml/OPMLParserTest.kt +++ b/api/src/test/java/com/readrops/api/opml/OPMLParserTest.kt @@ -25,11 +25,11 @@ class OPMLParserTest { assertEquals(foldersAndFeeds?.size, 6) - assertEquals(foldersAndFeeds?.get(Folder("Folder 1"))?.size, 2) - assertEquals(foldersAndFeeds?.get(Folder("Subfolder 1"))?.size, 4) - assertEquals(foldersAndFeeds?.get(Folder("Subfolder 2"))?.size, 1) - assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 1"))?.size, 2) - assertEquals(foldersAndFeeds?.get(Folder("Sub subfolder 2"))?.size, 0) + assertEquals(foldersAndFeeds?.get(Folder(name = "Folder 1"))?.size, 2) + assertEquals(foldersAndFeeds?.get(Folder(name = "Subfolder 1"))?.size, 4) + assertEquals(foldersAndFeeds?.get(Folder(name = "Subfolder 2"))?.size, 1) + assertEquals(foldersAndFeeds?.get(Folder(name = "Sub subfolder 1"))?.size, 2) + assertEquals(foldersAndFeeds?.get(Folder(name = "Sub subfolder 2"))?.size, 0) assertEquals(foldersAndFeeds?.get(null)?.size, 2) stream.close() @@ -68,11 +68,11 @@ class OPMLParserTest { val outputStream = FileOutputStream(file) val foldersAndFeeds: Map> = HashMap>().apply { - put(null, listOf(Feed("Feed1", "", "https://feed1.com"), - Feed("Feed2", "", "https://feed2.com"))) - put(Folder("Folder1"), listOf()) - put(Folder("Folder2"), listOf(Feed("Feed3", "", "https://feed3.com"), - Feed("Feed4", "", "https://feed4.com"))) + put(null, listOf(Feed(name = "Feed1", url = "https://feed1.com"), + Feed(name = "Feed2", url = "https://feed2.com"))) + put(Folder(name = "Folder1"), listOf()) + put(Folder(name = "Folder2"), listOf(Feed(name = "Feed3", url = "https://feed3.com"), + Feed(name = "Feed4", url ="https://feed4.com"))) } OPMLParser.write(foldersAndFeeds, outputStream) @@ -87,8 +87,8 @@ class OPMLParserTest { OPMLParser.read(inputStream).subscribe { result -> foldersAndFeeds2 = result } assertEquals(foldersAndFeeds.size, foldersAndFeeds2?.size) - assertEquals(foldersAndFeeds[Folder("Folder1")]?.size, foldersAndFeeds2?.get(Folder("Folder1"))?.size) - assertEquals(foldersAndFeeds[Folder("Folder2")]?.size, foldersAndFeeds2?.get(Folder("Folder2"))?.size) + assertEquals(foldersAndFeeds[Folder(name = "Folder1")]?.size, foldersAndFeeds2?.get(Folder(name = "Folder1"))?.size) + assertEquals(foldersAndFeeds[Folder(name = "Folder2")]?.size, foldersAndFeeds2?.get(Folder(name = "Folder2"))?.size) assertEquals(foldersAndFeeds[null]?.size, foldersAndFeeds2?.get(null)?.size) inputStream.close() diff --git a/db/src/main/java/com/readrops/db/dao/FeedDao.kt b/db/src/main/java/com/readrops/db/dao/FeedDao.kt index 6cf64ce6..9cd24948 100644 --- a/db/src/main/java/com/readrops/db/dao/FeedDao.kt +++ b/db/src/main/java/com/readrops/db/dao/FeedDao.kt @@ -3,6 +3,7 @@ package com.readrops.db.dao import androidx.lifecycle.LiveData import androidx.room.Dao import androidx.room.Query +import androidx.room.RoomWarnings import androidx.room.Transaction import com.readrops.db.entities.Feed import com.readrops.db.entities.account.Account @@ -57,11 +58,13 @@ abstract class FeedDao : BaseDao { @Query("Update Feed set text_color = :textColor, background_color = :bgColor Where id = :feedId") abstract fun updateColors(feedId: Int, textColor: Int, bgColor: Int) + @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) @Query("Select Feed.name as feed_name, Feed.id as feed_id, Folder.name as folder_name, Folder.id as folder_id, Folder.remoteId as folder_remoteId, Folder.account_id as folder_account_id," + "Feed.description as feed_description, Feed.icon_url as feed_icon_url, Feed.url as feed_url, Feed.folder_id as feed_folder_id, Feed.text_color as feed_text_color, Feed.background_color as feed_background_color" + ", Feed.account_id as feed_account_id, Feed.notification_enabled as feed_notification_enabled, Feed.siteUrl as feed_siteUrl, Feed.remoteId as feed_remoteId from Feed Left Join Folder on Feed.folder_id = Folder.id Where Feed.account_id = :accountId Order by Feed.name") abstract fun getAllFeedsWithFolder(accountId: Int): LiveData> + @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) @Query("Select id, name, icon_url, notification_enabled, text_color, background_color, account_id From Feed Where account_id = :accountId") abstract fun getFeedsForNotifPermission(accountId: Int): LiveData>