Compare commits
No commits in common. "8b0bbe71c9d0b551feb3f363425e306446e4fd5b" and "023a30c00816f380fde4b9d836bf8e19282b0153" have entirely different histories.
8b0bbe71c9
...
023a30c008
@ -66,19 +66,12 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
} else {
|
} else {
|
||||||
if (appSettingsService.isItemCachingEnabled()) {
|
if (appSettingsService.isItemCachingEnabled()) {
|
||||||
fromDB = true
|
fromDB = true
|
||||||
var dbItems = getDBItems().filter {
|
|
||||||
displayedItems == ItemType.ALL ||
|
|
||||||
(it.unread && displayedItems == ItemType.UNREAD) ||
|
|
||||||
(it.starred && displayedItems == ItemType.STARRED)
|
|
||||||
}
|
|
||||||
if (tagFilter != null) {
|
|
||||||
dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter!!.tag) }
|
|
||||||
}
|
|
||||||
if (sourceFilter != null) {
|
|
||||||
dbItems = dbItems.filter { it.sourcetitle == sourceFilter!!.title }
|
|
||||||
}
|
|
||||||
fetchedItems = SelfossModel.StatusAndData.succes(
|
fetchedItems = SelfossModel.StatusAndData.succes(
|
||||||
dbItems.map { it.toView() }
|
getDBItems().filter {
|
||||||
|
displayedItems == ItemType.ALL ||
|
||||||
|
(it.unread && displayedItems == ItemType.UNREAD) ||
|
||||||
|
(it.starred && displayedItems == ItemType.STARRED)
|
||||||
|
}.map { it.toView() }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,6 @@ fun SelfossModel.Item.toEntity(): ITEM =
|
|||||||
this.thumbnail,
|
this.thumbnail,
|
||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle.getHtmlDecoded(),
|
this.title.getHtmlDecoded(),
|
||||||
this.tags.joinToString(",")
|
this.tags.joinToString(",")
|
||||||
)
|
)
|
@ -173,60 +173,6 @@ class RepositoryTest() {
|
|||||||
verify(atLeast = 1) { db.itemsQueries.items().executeAsList()}
|
verify(atLeast = 1) { db.itemsQueries.items().executeAsList()}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `Get newer items without connectivity and tag filter`() {
|
|
||||||
val itemParameter1 = FakeItemParameters()
|
|
||||||
val itemParameter2 = FakeItemParameters()
|
|
||||||
val itemParameter3 = FakeItemParameters()
|
|
||||||
itemParameter2.tags = "Test, Stuff"
|
|
||||||
itemParameter2.id = "2"
|
|
||||||
itemParameter3.tags = "Other, Tag"
|
|
||||||
itemParameter3.id = "3"
|
|
||||||
coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) +
|
|
||||||
generateTestDBItems(itemParameter2) +
|
|
||||||
generateTestDBItems(itemParameter3)
|
|
||||||
|
|
||||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
|
||||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
|
||||||
|
|
||||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
|
||||||
repository.tagFilter = SelfossModel.Tag("Test", "red", 3)
|
|
||||||
runBlocking {
|
|
||||||
repository.getNewerItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
assertSame(repository.items.size, 1)
|
|
||||||
coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) }
|
|
||||||
verify(atLeast = 1) { db.itemsQueries.items().executeAsList()}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `Get newer items without connectivity and source filter`() {
|
|
||||||
val itemParameter1 = FakeItemParameters()
|
|
||||||
val itemParameter2 = FakeItemParameters()
|
|
||||||
val itemParameter3 = FakeItemParameters()
|
|
||||||
itemParameter2.sourcetitle = "Test"
|
|
||||||
itemParameter2.id = "2"
|
|
||||||
itemParameter3.sourcetitle = "Other"
|
|
||||||
itemParameter3.id = "3"
|
|
||||||
coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) +
|
|
||||||
generateTestDBItems(itemParameter2) +
|
|
||||||
generateTestDBItems(itemParameter3)
|
|
||||||
|
|
||||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
|
||||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
|
||||||
|
|
||||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
|
||||||
repository.sourceFilter = SelfossModel.Source(1, "Test", listOf("tags"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")
|
|
||||||
runBlocking {
|
|
||||||
repository.getNewerItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
assertSame(repository.items.size, 1)
|
|
||||||
coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) }
|
|
||||||
verify(atLeast = 1) { db.itemsQueries.items().executeAsList()}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Get older items`() {
|
fun `Get older items`() {
|
||||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||||
@ -1052,6 +998,6 @@ class FakeItemParameters() {
|
|||||||
val thumbnail = null
|
val thumbnail = null
|
||||||
val icon = "ba79e238383ce83c23a169929c8906ef.png"
|
val icon = "ba79e238383ce83c23a169929c8906ef.png"
|
||||||
val link = "https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/"
|
val link = "https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/"
|
||||||
var sourcetitle = "La Chimica e la Società"
|
val sourcetitle = "La Chimica e la Società"
|
||||||
var tags = "Chimica, Testing"
|
val tags = "Chimica, Testing"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user