1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-02-02 10:16:50 +01:00

Make models for getIndexes have default values.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-08-11 21:01:02 +02:00
parent 23fd3b03fb
commit 437877750c
5 changed files with 18 additions and 12 deletions

View File

@ -161,10 +161,10 @@ class SubsonicAPIClientTest {
assertResponseSuccessful(response)
response.body().indexes `should not be` null
with(response.body().indexes!!) {
with(response.body().indexes) {
lastModified `should equal` 1491069027523
ignoredArticles `should equal` "The El La Los Las Le Les"
shortcuts `should be` null
shortcuts `should be` emptyList<Index>()
indexList `should equal` mutableListOf(
Index("A", listOf(
Artist(50L, "Ace Of Base", parseDate("2017-04-02T20:16:29.815Z")),
@ -220,7 +220,13 @@ class SubsonicAPIClientTest {
fun `Should parse get indexes error response`() {
val response = checkErrorCallParsed { client.api.getIndexes(null, null).execute() }
response.indexes `should be` null
response.indexes `should not be` null
with(response.indexes) {
lastModified `should equal to` 0
ignoredArticles `should equal to` ""
indexList.size `should equal to` 0
shortcuts.size `should equal to` 0
}
}
@Test

View File

@ -2,6 +2,6 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class Artist(val id: Long,
val name: String,
data class Artist(val id: Long = -1,
val name: String = "",
val starred: Calendar?)

View File

@ -2,6 +2,6 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Index(val name: String,
data class Index(val name: String = "",
@JsonProperty("artist")
val artists: List<Artist>)
val artists: List<Artist> = emptyList())

View File

@ -2,8 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Indexes(val lastModified: Long,
val ignoredArticles: String?,
data class Indexes(val lastModified: Long = 0,
val ignoredArticles: String = "",
@JsonProperty("index")
val indexList: List<Index>,
val shortcuts: List<Index>?)
val indexList: List<Index> = emptyList(),
val shortcuts: List<Index> = emptyList())

View File

@ -7,5 +7,5 @@ import org.moire.ultrasonic.api.subsonic.models.Indexes
class GetIndexesResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val indexes: Indexes?) :
val indexes: Indexes = Indexes()) :
SubsonicResponse(status, version, error)