Add adapter for Fever items ids call

This commit is contained in:
Shinokuni 2021-12-25 19:08:25 +01:00
parent 76cd9355f8
commit 5975458011
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package com.readrops.api.services.fever.adapters
import com.readrops.api.TestUtils
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import okio.Buffer
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
class FeverFaviconsAdapterTest {
private val adapter = Moshi.Builder()
.add(FeverFaviconsAdapter())
.build()
.adapter<List<Favicon>>(Types.newParameterizedType(List::class.java, Favicon::class.java))
@Test
fun validFaviconsTest() {
val stream = TestUtils.loadResource("services/fever/favicons.json")
val favicons = adapter.fromJson(Buffer().readFrom(stream))!!
assertEquals(favicons.size, 3)
with(favicons[0]) {
assertEquals(id, 85)
assertNotNull(data)
}
}
}

View File

@ -0,0 +1,25 @@
package com.readrops.api.services.fever.adapters
import com.readrops.api.TestUtils
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import okio.Buffer
import org.junit.Test
import kotlin.test.assertEquals
class FeverItemsIdsAdapterTest {
private val adapter = Moshi.Builder()
.add(FeverItemsIdsAdapter())
.build()
.adapter<List<String>>(Types.newParameterizedType(List::class.java, String::class.java))
@Test
fun validIdsTest() {
val stream = TestUtils.loadResource("services/fever/itemsIds.json")
val ids = adapter.fromJson(Buffer().readFrom(stream))!!
assertEquals(ids.size, 6)
}
}

View File

@ -0,0 +1,6 @@
{
"api_version": 3,
"auth": 1,
"last_refreshed_on_time": 1635849601,
"unread_item_ids": "1564058340320120,1564058340320124,1564058340320127,1564058340320128,1564058340320134,1564058340320135"
}