mirror of https://github.com/readrops/Readrops.git
Add adapter for Fever items ids call
This commit is contained in:
parent
76cd9355f8
commit
5975458011
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"api_version": 3,
|
||||
"auth": 1,
|
||||
"last_refreshed_on_time": 1635849601,
|
||||
"unread_item_ids": "1564058340320120,1564058340320124,1564058340320127,1564058340320128,1564058340320134,1564058340320135"
|
||||
}
|
Loading…
Reference in New Issue