Use default values for getMusicDirectory response.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-08-18 10:06:34 +02:00
parent decf680076
commit 0920cc94a8
5 changed files with 130 additions and 54 deletions

View File

@ -2,6 +2,7 @@ package org.moire.ultrasonic.api.subsonic
import org.amshove.kluent.`should be`
import org.amshove.kluent.`should contain`
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.amshove.kluent.`should not be`
import org.junit.Test
@ -17,7 +18,17 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
client.api.getMusicDirectory(1).execute()
})
response.musicDirectory `should be` null
with(response.musicDirectory) {
this `should not be` null
id `should equal to` -1L
parent `should equal to` -1L
name `should equal to` ""
userRating `should equal to` 0
averageRating `should equal to` 0.0f
starred `should be` null
playCount `should equal to` 0
childList `should be` emptyList<MusicDirectoryChild>()
}
}
@Test
@ -39,17 +50,29 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
response.body().musicDirectory `should not be` null
with(response.body().musicDirectory!!) {
id `should equal` 382L
name `should equal` "AC_DC"
starred `should equal` parseDate("2017-04-02T20:16:29.815Z")
with(response.body().musicDirectory) {
id `should equal to` 4836L
parent `should equal to` 300L
name `should equal` "12 Stones"
userRating `should equal to` 5
averageRating `should equal to` 5.0f
starred `should equal` null
playCount `should equal to` 1
childList.size `should be` 2
childList[0] `should equal` MusicDirectoryChild(583L, 382L, true, "Black Ice",
"Black Ice", "AC/DC", 2008, "Hard Rock", 583L,
parseDate("2016-10-23T15:31:22.000Z"), parseDate("2017-04-02T20:16:15.724Z"))
childList[1] `should equal` MusicDirectoryChild(582L, 382L, true, "Rock or Bust",
"Rock or Bust", "AC/DC", 2014, "Hard Rock", 582L,
parseDate("2016-10-23T15:31:24.000Z"), null)
childList[0] `should equal` MusicDirectoryChild(id = 4844L, parent = 4836L, isDir = false,
title = "Crash", album = "12 Stones", artist = "12 Stones", track = 1, year = 2002,
genre = "Alternative Rock", coverArt = 4836L, size = 5348318L,
contentType = "audio/mpeg", suffix = "mp3", duration = 222, bitRate = 192,
path = "12 Stones/12 Stones/01 Crash.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:19:10.000Z"),
albumId = 454L, artistId = 288L, type = "music")
childList[1] `should equal` MusicDirectoryChild(id = 4845L, parent = 4836L, isDir = false,
title = "Broken", album = "12 Stones", artist = "12 Stones", track = 2, year = 2002,
genre = "Alternative Rock", coverArt = 4836L, size = 4309043L,
contentType = "audio/mpeg", suffix = "mp3", duration = 179, bitRate = 192,
path = "12 Stones/12 Stones/02 Broken.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:19:09.000Z"),
albumId = 454L, artistId = 288L, type = "music")
}
}
}

View File

@ -1,35 +1,63 @@
{
"subsonic-response" : {
"status" : "ok",
"version" : "1.13.0",
"directory" : {
"id" : "382",
"name" : "AC_DC",
"starred" : "2017-04-02T20:16:29.815Z",
"child" : [ {
"id" : "583",
"parent" : "382",
"isDir" : true,
"title" : "Black Ice",
"album" : "Black Ice",
"artist" : "AC/DC",
"year" : 2008,
"genre" : "Hard Rock",
"coverArt" : "583",
"created" : "2016-10-23T15:31:22.000Z",
"starred" : "2017-04-02T20:16:15.724Z"
}, {
"id" : "582",
"parent" : "382",
"isDir" : true,
"title" : "Rock or Bust",
"album" : "Rock or Bust",
"artist" : "AC/DC",
"year" : 2014,
"genre" : "Hard Rock",
"coverArt" : "582",
"created" : "2016-10-23T15:31:24.000Z"
} ]
}
}
}
"subsonic-response" : {
"status" : "ok",
"version" : "1.15.0",
"directory" : {
"id" : "4836",
"parent" : "300",
"name" : "12 Stones",
"userRating" : 5,
"averageRating" : 5.0,
"playCount" : 1,
"child" : [ {
"id" : "4844",
"parent" : "4836",
"isDir" : false,
"title" : "Crash",
"album" : "12 Stones",
"artist" : "12 Stones",
"track" : 1,
"year" : 2002,
"genre" : "Alternative Rock",
"coverArt" : "4836",
"size" : 5348318,
"contentType" : "audio/mpeg",
"suffix" : "mp3",
"duration" : 222,
"bitRate" : 192,
"path" : "12 Stones/12 Stones/01 Crash.mp3",
"isVideo" : false,
"playCount" : 0,
"discNumber" : 1,
"created" : "2016-10-23T15:19:10.000Z",
"albumId" : "454",
"artistId" : "288",
"type" : "music"
}, {
"id" : "4845",
"parent" : "4836",
"isDir" : false,
"title" : "Broken",
"album" : "12 Stones",
"artist" : "12 Stones",
"track" : 2,
"year" : 2002,
"genre" : "Alternative Rock",
"coverArt" : "4836",
"size" : 4309043,
"contentType" : "audio/mpeg",
"suffix" : "mp3",
"duration" : 179,
"bitRate" : 192,
"path" : "12 Stones/12 Stones/02 Broken.mp3",
"isVideo" : false,
"playCount" : 0,
"discNumber" : 1,
"created" : "2016-10-23T15:19:09.000Z",
"albumId" : "454",
"artistId" : "288",
"type" : "music"
} ]
}
}
}

View File

@ -3,8 +3,12 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class MusicDirectory(val id: Long,
val name: String,
val starred: Calendar?,
data class MusicDirectory(val id: Long = -1L,
val parent: Long = -1L,
val name: String = "",
val userRating: Int = 0,
val averageRating: Float = 0.0f,
val starred: Calendar? = null,
val playCount: Int = 0,
@JsonProperty("child")
val childList: List<MusicDirectoryChild> = emptyList())

View File

@ -2,8 +2,29 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class MusicDirectoryChild(val id: Long, val parent: Long, val isDir: Boolean = false,
val title: String = "", val album: String = "",
val artist: String = "", val year: Int?,
val genre: String = "", val coverArt: Long = -1,
val created: Calendar, val starred: Calendar?)
data class MusicDirectoryChild(val id: Long = -1L,
val parent: Long = -1L,
val isDir: Boolean = false,
val title: String = "",
val album: String = "",
val artist: String = "",
val track: Int = -1,
val year: Int? = null,
val genre: String = "",
val coverArt: Long? = null,
val size: Long = -1,
val contentType: String = "",
val suffix: String = "",
val transcodedContentType: String = "",
val transcodedSuffix: String = "",
val duration: Int = -1,
val bitRate: Int = -1,
val path: String = "",
val isVideo: Boolean = false,
val playCount: Int = 0,
val discNumber: Int = -1,
val created: Calendar? = null,
val albumId: Long = -1,
val artistId: Long = -1,
val type: String = "",
val starred: Calendar? = null)

View File

@ -9,5 +9,5 @@ class GetMusicDirectoryResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("directory")
val musicDirectory: MusicDirectory?) :
val musicDirectory: MusicDirectory = MusicDirectory()) :
SubsonicResponse(status, version, error)