| author | Da Risk <da_risk@geekorum.com> |
| Wed, 12 Jan 2022 17:29:59 -0400 | |
| changeset 882 | 7a74abf66c49 |
| parent 846 | ac0863af5ef6 |
| child 920 | ae014043f4fa |
| permissions | -rw-r--r-- |
|
137
5464f07a306c
Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents:
37
diff
changeset
|
1 |
/* |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
2 |
* Geekttrss is a RSS feed reader application on the Android Platform. |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
3 |
* |
| 882 | 4 |
* Copyright (C) 2017-2022 by Frederic-Charles Barthelery. |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
5 |
* |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
6 |
* This file is part of Geekttrss. |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
7 |
* |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
8 |
* Geekttrss is free software: you can redistribute it and/or modify |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
9 |
* it under the terms of the GNU General Public License as published by |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
11 |
* (at your option) any later version. |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
12 |
* |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
13 |
* Geekttrss is distributed in the hope that it will be useful, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
16 |
* GNU General Public License for more details. |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
17 |
* |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License |
| 24 | 19 |
* along with Geekttrss. If not, see <http://www.gnu.org/licenses/>. |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
20 |
*/ |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
21 |
package com.geekorum.ttrss.data |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
22 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
23 |
import android.database.sqlite.SQLiteDatabase |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
24 |
import androidx.arch.core.executor.testing.InstantTaskExecutorRule |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
25 |
import androidx.core.content.contentValuesOf |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
26 |
import androidx.paging.AsyncPagingDataDiffer |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
27 |
import androidx.paging.Pager |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
28 |
import androidx.paging.PagingConfig |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
29 |
import androidx.recyclerview.widget.DiffUtil |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
30 |
import androidx.recyclerview.widget.ListUpdateCallback |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
31 |
import androidx.room.Room |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
32 |
import androidx.sqlite.db.SupportSQLiteDatabase |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
33 |
import androidx.test.core.app.ApplicationProvider |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
34 |
import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 573 | 35 |
import com.geekorum.ttrss.data.ArticlesDatabase.Tables |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
36 |
import com.geekorum.ttrss.providers.ArticlesContract |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
37 |
import com.google.common.truth.Truth.assertThat |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
38 |
import kotlinx.coroutines.flow.collect |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
39 |
import kotlinx.coroutines.flow.first |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
40 |
import kotlinx.coroutines.flow.take |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
41 |
import kotlinx.coroutines.launch |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
42 |
import kotlinx.coroutines.runBlocking |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
43 |
import org.junit.Rule |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
44 |
import org.junit.runner.RunWith |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
45 |
import kotlin.test.BeforeTest |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
46 |
import kotlin.test.Test |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
47 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
48 |
@RunWith(AndroidJUnit4::class) |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
49 |
class ArticleFullTextSearchTest {
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
50 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
51 |
@get:Rule |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
52 |
val roomRule = InstantTaskExecutorRule() |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
53 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
54 |
private lateinit var database: ArticlesDatabase |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
55 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
56 |
@BeforeTest |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
57 |
fun beforeTest() {
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
58 |
database = Room.inMemoryDatabaseBuilder(ApplicationProvider.getApplicationContext(), |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
59 |
ArticlesDatabase::class.java) |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
60 |
.allowMainThreadQueries() |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
61 |
.build() |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
62 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
63 |
createSomeArticles(database.openHelper.writableDatabase) |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
64 |
} |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
65 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
66 |
@Test |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
67 |
fun testAnFTSSearchPagedList() {
|
| 783 | 68 |
val expected = ArticleWithFeed( |
69 |
article = Article( |
|
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
70 |
id = 1, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
71 |
contentData = ArticleContentIndexed( |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
72 |
title = "Comment Linux est devenu un enjeu strategique pour la silicon valley", |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
73 |
content = """L’emblématique système d’exploitation libre est devenu un outil-clé |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
74 |
|de tous les grands groupes du Web, comme l’illustre le rachat de Red Hat. […]""".trimMargin(), |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
75 |
tags = "article tags", |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
76 |
author = "article author" |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
77 |
), |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
78 |
score = 0, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
79 |
isPublished = true, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
80 |
lastTimeUpdate = 0, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
81 |
isUnread = true, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
82 |
isTransientUnread = true, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
83 |
isStarred = true, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
84 |
isUpdated = true, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
85 |
feedId = 1, |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
86 |
link = "article links", |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
87 |
flavorImageUri = "article flavor image uri", |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
88 |
contentExcerpt = "a content excerpt" |
| 783 | 89 |
), |
90 |
feed = Feed(id = 1, |
|
91 |
url = "feed url", |
|
92 |
title = "feed title", |
|
93 |
catId = 0, |
|
94 |
displayTitle = "display title", |
|
95 |
lastTimeUpdate = 0, |
|
96 |
unreadCount = 2, |
|
97 |
isSubscribed = true, |
|
98 |
feedIconUrl = "http://exemple.com/1.ico" |
|
99 |
)) |
|
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
100 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
101 |
val articleDao = database.articleDao() |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
102 |
val differ = AsyncPagingDataDiffer(ARTICLE_DIFF_CALLBACK, NoOpUpdateCallback) |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
103 |
val pager = Pager(PagingConfig(10)) {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
104 |
articleDao.searchArticles("linux")
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
105 |
} |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
106 |
|
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
107 |
runBlocking {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
108 |
val submitJob = launch {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
109 |
val data = pager.flow.first() |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
110 |
differ.submitData(data) |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
111 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
112 |
// wait for the load: initial notLoading, Loading, notLoading |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
113 |
differ.loadStateFlow.take(3).collect() |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
114 |
submitJob.cancel() |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
115 |
} |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
116 |
assertThat(differ.snapshot()).containsExactly(expected) |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
117 |
} |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
118 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
119 |
|
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
120 |
private fun createSomeArticles(db: SupportSQLiteDatabase) {
|
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
121 |
var values = contentValuesOf( |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
122 |
ArticlesContract.Category._ID to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
123 |
ArticlesContract.Category.TITLE to "category", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
124 |
ArticlesContract.Category.UNREAD_COUNT to 2 |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
125 |
) |
| 573 | 126 |
db.insert(Tables.CATEGORIES, SQLiteDatabase.CONFLICT_NONE, values) |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
127 |
|
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
128 |
values = contentValuesOf( |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
129 |
ArticlesContract.Feed.TITLE to "feed title", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
130 |
ArticlesContract.Feed.URL to "feed url", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
131 |
ArticlesContract.Feed.CAT_ID to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
132 |
ArticlesContract.Feed.UNREAD_COUNT to 2, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
133 |
ArticlesContract.Feed.LAST_TIME_UPDATE to 0, |
| 202 | 134 |
ArticlesContract.Feed.DISPLAY_TITLE to "display title", |
|
440
2e52ffdc0735
data: add Feed.feed_icon_url column
Da Risk <da_risk@geekorum.com>
parents:
202
diff
changeset
|
135 |
ArticlesContract.Feed.IS_SUBSCRIBED to 1, |
|
2e52ffdc0735
data: add Feed.feed_icon_url column
Da Risk <da_risk@geekorum.com>
parents:
202
diff
changeset
|
136 |
ArticlesContract.Feed.ICON_URL to "http://exemple.com/1.ico" |
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
137 |
) |
| 573 | 138 |
db.insert(Tables.FEEDS, SQLiteDatabase.CONFLICT_NONE, values) |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
139 |
|
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
140 |
values = contentValuesOf( |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
141 |
ArticlesContract.Article._ID to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
142 |
ArticlesContract.Article.TITLE to "article title", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
143 |
ArticlesContract.Article.CONTENT to "a content", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
144 |
ArticlesContract.Article.SCORE to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
145 |
ArticlesContract.Article.PUBLISHED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
146 |
ArticlesContract.Article.LAST_TIME_UPDATE to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
147 |
ArticlesContract.Article.UNREAD to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
148 |
ArticlesContract.Article.TRANSIENT_UNREAD to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
149 |
ArticlesContract.Article.STARRED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
150 |
ArticlesContract.Article.IS_UPDATED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
151 |
ArticlesContract.Article.FEED_ID to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
152 |
ArticlesContract.Article.LINK to "article links", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
153 |
ArticlesContract.Article.TAGS to "article tags", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
154 |
ArticlesContract.Article.AUTHOR to "article author", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
155 |
ArticlesContract.Article.FLAVOR_IMAGE_URI to "article flavor image uri", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
156 |
ArticlesContract.Article.CONTENT_EXCERPT to "a content excerpt" |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
157 |
) |
| 573 | 158 |
db.insert(Tables.ARTICLES, SQLiteDatabase.CONFLICT_NONE, values) |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
159 |
|
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
160 |
values = contentValuesOf( |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
161 |
ArticlesContract.Article._ID to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
162 |
ArticlesContract.Article.TITLE to "Comment Linux est devenu un enjeu strategique pour la silicon valley", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
163 |
ArticlesContract.Article.CONTENT to """L’emblématique système d’exploitation libre est devenu un outil-clé |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
164 |
|de tous les grands groupes du Web, comme l’illustre le rachat de Red Hat. […]""".trimMargin(), |
|
37
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
165 |
ArticlesContract.Article.SCORE to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
166 |
ArticlesContract.Article.PUBLISHED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
167 |
ArticlesContract.Article.LAST_TIME_UPDATE to 0, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
168 |
ArticlesContract.Article.UNREAD to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
169 |
ArticlesContract.Article.TRANSIENT_UNREAD to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
170 |
ArticlesContract.Article.STARRED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
171 |
ArticlesContract.Article.IS_UPDATED to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
172 |
ArticlesContract.Article.FEED_ID to 1, |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
173 |
ArticlesContract.Article.LINK to "article links", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
174 |
ArticlesContract.Article.TAGS to "article tags", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
175 |
ArticlesContract.Article.AUTHOR to "article author", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
176 |
ArticlesContract.Article.FLAVOR_IMAGE_URI to "article flavor image uri", |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
177 |
ArticlesContract.Article.CONTENT_EXCERPT to "a content excerpt" |
|
86222b4631ae
Database: don't use transactions during Migrations and tests it's not useful
Da Risk <da_risk@geekorum.com>
parents:
24
diff
changeset
|
178 |
) |
| 573 | 179 |
db.insert(Tables.ARTICLES, SQLiteDatabase.CONFLICT_NONE, values) |
|
23
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
180 |
} |
|
9797095c0fc7
ArticleDao: allow to search for an article
Da Risk <da_risk@geekorum.com>
parents:
diff
changeset
|
181 |
} |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
182 |
|
|
766
90f041aa0e53
app: ArticlesRepository returns ArticleWithFeed info
Da Risk <da_risk@geekorum.com>
parents:
762
diff
changeset
|
183 |
private val ARTICLE_DIFF_CALLBACK = object : DiffUtil.ItemCallback<ArticleWithFeed>() {
|
|
90f041aa0e53
app: ArticlesRepository returns ArticleWithFeed info
Da Risk <da_risk@geekorum.com>
parents:
762
diff
changeset
|
184 |
override fun areItemsTheSame(oldItem: ArticleWithFeed, newItem: ArticleWithFeed): Boolean {
|
|
90f041aa0e53
app: ArticlesRepository returns ArticleWithFeed info
Da Risk <da_risk@geekorum.com>
parents:
762
diff
changeset
|
185 |
return oldItem.article.id == newItem.article.id |
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
186 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
187 |
|
|
766
90f041aa0e53
app: ArticlesRepository returns ArticleWithFeed info
Da Risk <da_risk@geekorum.com>
parents:
762
diff
changeset
|
188 |
override fun areContentsTheSame(oldItem: ArticleWithFeed, newItem: ArticleWithFeed): Boolean {
|
|
762
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
189 |
return oldItem == newItem |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
190 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
191 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
192 |
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
193 |
private val NoOpUpdateCallback = object : ListUpdateCallback {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
194 |
override fun onInserted(position: Int, count: Int) {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
195 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
196 |
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
197 |
override fun onRemoved(position: Int, count: Int) {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
198 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
199 |
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
200 |
override fun onMoved(fromPosition: Int, toPosition: Int) {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
201 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
202 |
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
203 |
override fun onChanged(position: Int, count: Int, payload: Any?) {
|
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
204 |
} |
|
09baa075a33c
app: ArticleFullTextSearchTest convert test to paging3
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
205 |
} |