Update test data
parent
62088b36a4
commit
206fb4e584
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"title": "Read later",
|
||||||
|
"sortKey": 1,
|
||||||
|
"order": "NEWEST",
|
||||||
|
"createdAt": 1335906000000,
|
||||||
|
"isTrackingEnabled": true
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": null,
|
||||||
|
"description": null,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
@ -1,102 +1,57 @@
|
|||||||
package org.koitharu.kotatsu
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import com.squareup.moshi.*
|
||||||
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
|
import okio.buffer
|
||||||
|
import okio.source
|
||||||
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||||
import org.koitharu.kotatsu.parsers.model.*
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
object SampleData {
|
object SampleData {
|
||||||
|
|
||||||
val manga = Manga(
|
private val moshi = Moshi.Builder()
|
||||||
id = 1105355890252749533,
|
.add(DateAdapter())
|
||||||
title = "Sasurai Emanon",
|
.add(KotlinJsonAdapterFactory())
|
||||||
altTitle = null,
|
.build()
|
||||||
url = "/manga/sasurai_emanon/",
|
|
||||||
publicUrl = "https://www.mangatown.com/manga/sasurai_emanon/",
|
|
||||||
rating = 1.0f,
|
|
||||||
isNsfw = false,
|
|
||||||
coverUrl = "https://fmcdn.mangahere.com/store/manga/10992/ocover.jpg?token=905148d2f052f9d3604135933b958771c8b00077&ttl=1658214000&v=1578490983",
|
|
||||||
tags = setOf(
|
|
||||||
MangaTag(title = "Adventure", key = "0-adventure-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Mature", key = "0-mature-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Psychological", key = "0-psychological-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Slice Of Life", key = "0-slice_of_life-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Supernatural", key = "0-supernatural-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
),
|
|
||||||
state = MangaState.ONGOING,
|
|
||||||
author = "Kajio Shinji",
|
|
||||||
largeCoverUrl = null,
|
|
||||||
source = MangaSource.MANGATOWN,
|
|
||||||
)
|
|
||||||
|
|
||||||
val mangaDetails = manga.copy(
|
val manga: Manga
|
||||||
tags = setOf(
|
get() = loadAsset("manga/header.json", Manga::class)
|
||||||
MangaTag(title = "Adventure", key = "0-adventure-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Mature", key = "0-mature-0-0-0-0", source = MangaSource.MANGATOWN),
|
val mangaDetails: Manga
|
||||||
MangaTag(title = "Psychological", key = "0-psychological-0-0-0-0", source = MangaSource.MANGATOWN),
|
get() = loadAsset("manga/full.json", Manga::class)
|
||||||
MangaTag(title = "Slice Of Life", key = "0-slice_of_life-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
MangaTag(title = "Supernatural", key = "0-supernatural-0-0-0-0", source = MangaSource.MANGATOWN),
|
|
||||||
),
|
|
||||||
largeCoverUrl = null,
|
|
||||||
description = """
|
|
||||||
Based on the award-winning novel by Shinji Kajio, Memories of Emanon tells the story of a mysterious girl
|
|
||||||
who holds a 3-billion-year old memory, dating back to the moment life first appeared on Earth. The first
|
|
||||||
half of the volume is the colored Wandering Emanon '67 chapters (published before as Emanon Episode: 1).
|
|
||||||
The second half is Wandering Emanon set before the '67 chapters.
|
|
||||||
""".trimIndent(),
|
|
||||||
chapters = listOf(
|
|
||||||
MangaChapter(
|
|
||||||
id = -7214407414868456892,
|
|
||||||
name = "Sasurai Emanon - 1",
|
|
||||||
number = 1,
|
|
||||||
url = "/manga/sasurai_emanon/c001/",
|
|
||||||
scanlator = null,
|
|
||||||
uploadDate = 1335906000000,
|
|
||||||
branch = null,
|
|
||||||
source = MangaSource.MANGATOWN,
|
|
||||||
),
|
|
||||||
MangaChapter(
|
|
||||||
id = -7214407414868456861,
|
|
||||||
name = "Sasurai Emanon - 2",
|
|
||||||
number = 2,
|
|
||||||
url = "/manga/sasurai_emanon/c002/",
|
|
||||||
scanlator = null,
|
|
||||||
uploadDate = 1335906000000,
|
|
||||||
branch = null,
|
|
||||||
source = MangaSource.MANGATOWN,
|
|
||||||
),
|
|
||||||
MangaChapter(
|
|
||||||
id = -7214407414868456830,
|
|
||||||
name = "Sasurai Emanon - 3",
|
|
||||||
number = 3,
|
|
||||||
url = "/manga/sasurai_emanon/c003/",
|
|
||||||
scanlator = null,
|
|
||||||
uploadDate = 1335906000000,
|
|
||||||
branch = null,
|
|
||||||
source = MangaSource.MANGATOWN,
|
|
||||||
),
|
|
||||||
MangaChapter(
|
|
||||||
id = -7214407414868456799,
|
|
||||||
name = "Sasurai Emanon - 4",
|
|
||||||
number = 3,
|
|
||||||
url = "/manga/sasurai_emanon/c004/",
|
|
||||||
scanlator = null,
|
|
||||||
uploadDate = 1335906000000,
|
|
||||||
branch = null,
|
|
||||||
source = MangaSource.MANGATOWN,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
val tag = mangaDetails.tags.elementAt(2)
|
val tag = mangaDetails.tags.elementAt(2)
|
||||||
|
|
||||||
val chapter = checkNotNull(mangaDetails.chapters)[2]
|
val chapter = checkNotNull(mangaDetails.chapters)[2]
|
||||||
|
|
||||||
val favouriteCategory = FavouriteCategory(
|
val favouriteCategory: FavouriteCategory
|
||||||
id = 4,
|
get() = loadAsset("categories/simple.json", FavouriteCategory::class)
|
||||||
title = "Read later",
|
|
||||||
sortKey = 1,
|
fun <T : Any> loadAsset(name: String, cls: KClass<T>): T {
|
||||||
order = SortOrder.NEWEST,
|
val assets = InstrumentationRegistry.getInstrumentation().context.assets
|
||||||
createdAt = Date(1335906000000),
|
return assets.open(name).use {
|
||||||
isTrackingEnabled = true,
|
moshi.adapter(cls.java).fromJson(it.source().buffer())
|
||||||
)
|
} ?: throw RuntimeException("Cannot read asset from json \"$name\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DateAdapter : JsonAdapter<Date>() {
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
override fun fromJson(reader: JsonReader): Date? {
|
||||||
|
val ms = reader.nextLong()
|
||||||
|
return if (ms == 0L) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
Date(ms)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToJson
|
||||||
|
override fun toJson(writer: JsonWriter, value: Date?) {
|
||||||
|
writer.value(value?.time ?: 0L)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue