Add parsing shortcuts info.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
b02df33b9c
commit
13cf2cd8bf
|
@ -30,7 +30,7 @@ import java.util.TimeZone
|
|||
/**
|
||||
* Integration test for [SubsonicAPIClient] class.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
class SubsonicAPIClientTest {
|
||||
companion object {
|
||||
const val USERNAME = "some-user"
|
||||
|
@ -154,7 +154,6 @@ class SubsonicAPIClientTest {
|
|||
|
||||
@Test
|
||||
fun `Should parse get indexes ok response`() {
|
||||
// check for shortcut parsing
|
||||
enqueueResponse("get_indexes_ok.json")
|
||||
|
||||
val response = client.api.getIndexes(null, null).execute()
|
||||
|
@ -164,7 +163,10 @@ class SubsonicAPIClientTest {
|
|||
with(response.body().indexes) {
|
||||
lastModified `should equal` 1491069027523
|
||||
ignoredArticles `should equal` "The El La Los Las Le Les"
|
||||
shortcuts `should be` emptyList<Index>()
|
||||
shortcutList `should equal` listOf(
|
||||
Artist(889L, "podcasts", null),
|
||||
Artist(890L, "audiobooks", null)
|
||||
)
|
||||
indexList `should equal` mutableListOf(
|
||||
Index("A", listOf(
|
||||
Artist(50L, "Ace Of Base", parseDate("2017-04-02T20:16:29.815Z")),
|
||||
|
@ -225,7 +227,7 @@ class SubsonicAPIClientTest {
|
|||
lastModified `should equal to` 0
|
||||
ignoredArticles `should equal to` ""
|
||||
indexList.size `should equal to` 0
|
||||
shortcuts.size `should equal to` 0
|
||||
shortcutList.size `should equal to` 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
"indexes" : {
|
||||
"lastModified" : 1491069027523,
|
||||
"ignoredArticles" : "The El La Los Las Le Les",
|
||||
"shortcut" : [ {
|
||||
"id" : "889",
|
||||
"name" : "podcasts"
|
||||
},
|
||||
{
|
||||
"id" : "890",
|
||||
"name" : "audiobooks"
|
||||
} ],
|
||||
"index" : [ {
|
||||
"name" : "A",
|
||||
"artist" : [ {
|
||||
|
|
|
@ -6,4 +6,5 @@ data class Indexes(val lastModified: Long = 0,
|
|||
val ignoredArticles: String = "",
|
||||
@JsonProperty("index")
|
||||
val indexList: List<Index> = emptyList(),
|
||||
val shortcuts: List<Index> = emptyList())
|
||||
@JsonProperty("shortcut")
|
||||
val shortcutList: List<Artist> = emptyList())
|
||||
|
|
|
@ -16,7 +16,7 @@ fun List<APIMusicFolder>.toDomainEntityList(): List<MusicFolder>
|
|||
= this.map { it.toDomainEntity() }
|
||||
|
||||
fun APIIndexes.toDomainEntity(): Indexes = Indexes(this.lastModified, this.ignoredArticles,
|
||||
this.shortcuts.foldIndexToArtistList(), this.indexList.foldIndexToArtistList())
|
||||
this.shortcutList.map { it.toDomainEntity() }, this.indexList.foldIndexToArtistList())
|
||||
|
||||
private fun List<Index>.foldIndexToArtistList(): List<Artist> = this.fold(listOf(), {
|
||||
acc, index -> acc + index.artists.map { it.toDomainEntity() }
|
||||
|
@ -25,4 +25,4 @@ private fun List<Index>.foldIndexToArtistList(): List<Artist> = this.fold(listOf
|
|||
fun APIArtist.toDomainEntity(): Artist = Artist().apply {
|
||||
id = this@toDomainEntity.id.toString()
|
||||
name = this@toDomainEntity.name
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class APIConverterTest {
|
|||
val entity = createIndexes(154, "Le Tre Ze", listOf(
|
||||
createIndex("A", artistsA),
|
||||
createIndex("T", artistsT)
|
||||
), emptyList())
|
||||
), artistsA)
|
||||
|
||||
val convertedEntity = entity.toDomainEntity()
|
||||
|
||||
|
@ -74,7 +74,7 @@ class APIConverterTest {
|
|||
ignoredArticles `should equal to` entity.ignoredArticles
|
||||
artists.size `should equal to` expectedArtists.size
|
||||
artists `should equal` expectedArtists
|
||||
shortcuts `should equal` emptyList()
|
||||
shortcuts `should equal` artistsA.map { it.toDomainEntity() }.toMutableList()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,6 @@ class APIConverterTest {
|
|||
lastModified: Long = 0,
|
||||
ignoredArticles: String,
|
||||
indexList: List<Index> = emptyList(),
|
||||
shortcuts: List<Index> = emptyList()): Indexes
|
||||
shortcuts: List<Artist> = emptyList()): Indexes
|
||||
= Indexes(lastModified, ignoredArticles, indexList, shortcuts)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue