2017-08-20 22:04:41 +02:00
|
|
|
package org.moire.ultrasonic.api.subsonic
|
|
|
|
|
2018-03-24 19:30:03 +01:00
|
|
|
import org.amshove.kluent.`should be equal to`
|
2017-08-20 22:04:41 +02:00
|
|
|
import org.amshove.kluent.`should equal`
|
2017-08-29 22:18:53 +02:00
|
|
|
import org.amshove.kluent.`should not be`
|
2017-08-20 22:04:41 +02:00
|
|
|
import org.junit.Test
|
2017-08-29 22:18:53 +02:00
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Album
|
2017-08-20 22:04:41 +02:00
|
|
|
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Integration test for [SubsonicAPIClient] for getAlbum call.
|
|
|
|
*/
|
|
|
|
class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
|
|
|
|
@Test
|
|
|
|
fun `Should parse error responce`() {
|
2017-08-29 22:18:53 +02:00
|
|
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
2017-12-16 22:14:01 +01:00
|
|
|
client.api.getAlbum("56").execute()
|
2017-08-29 22:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
response.album `should not be` null
|
|
|
|
response.album `should equal` Album()
|
2017-08-20 22:04:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should add id to request params`() {
|
2017-12-16 22:14:01 +01:00
|
|
|
val id = "76"
|
2017-08-20 22:04:41 +02:00
|
|
|
|
2017-08-29 22:18:53 +02:00
|
|
|
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_ok.json",
|
|
|
|
expectedParam = "id=$id") {
|
|
|
|
client.api.getAlbum(id).execute()
|
|
|
|
}
|
2017-08-20 22:04:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should parse ok response`() {
|
|
|
|
mockWebServerRule.enqueueResponse("get_album_ok.json")
|
|
|
|
|
2017-12-16 22:14:01 +01:00
|
|
|
val response = client.api.getAlbum("512").execute()
|
2017-08-20 22:04:41 +02:00
|
|
|
|
|
|
|
assertResponseSuccessful(response)
|
2018-03-24 18:57:18 +01:00
|
|
|
with(response.body()!!.album) {
|
2018-03-24 19:30:03 +01:00
|
|
|
id `should be equal to` "618"
|
|
|
|
name `should be equal to` "Black Ice"
|
|
|
|
artist `should be equal to` "AC/DC"
|
|
|
|
artistId `should be equal to` "362"
|
|
|
|
coverArt `should be equal to` "al-618"
|
|
|
|
songCount `should be equal to` 15
|
|
|
|
duration `should be equal to` 3331
|
2017-08-20 22:04:41 +02:00
|
|
|
created `should equal` parseDate("2016-10-23T15:31:22.000Z")
|
2018-03-24 19:30:03 +01:00
|
|
|
year `should be equal to` 2008
|
|
|
|
genre `should be equal to` "Hard Rock"
|
|
|
|
songList.size `should be equal to` 15
|
2017-12-21 10:44:19 +01:00
|
|
|
songList[0] `should equal` MusicDirectoryChild(id = "6491", parent = "6475",
|
|
|
|
isDir = false, title = "Rock 'n' Roll Train", album = "Black Ice",
|
|
|
|
artist = "AC/DC", track = 1, year = 2008, genre = "Hard Rock",
|
|
|
|
coverArt = "6475", size = 7205451, contentType = "audio/mpeg", suffix = "mp3",
|
|
|
|
duration = 261, bitRate = 219,
|
|
|
|
path = "AC_DC/Black Ice/01 Rock 'n' Roll Train.mp3",
|
|
|
|
isVideo = false, playCount = 0, discNumber = 1,
|
|
|
|
created = parseDate("2016-10-23T15:31:20.000Z"),
|
2017-12-16 21:28:18 +01:00
|
|
|
albumId = "618", artistId = "362", type = "music")
|
2017-12-21 10:44:19 +01:00
|
|
|
songList[5] `should equal` MusicDirectoryChild(id = "6492", parent = "6475",
|
|
|
|
isDir = false, title = "Smash 'n' Grab", album = "Black Ice", artist = "AC/DC",
|
|
|
|
track = 6, year = 2008, genre = "Hard Rock", coverArt = "6475", size = 6697204,
|
2017-08-20 22:04:41 +02:00
|
|
|
contentType = "audio/mpeg", suffix = "mp3", duration = 246, bitRate = 216,
|
|
|
|
path = "AC_DC/Black Ice/06 Smash 'n' Grab.mp3", isVideo = false, playCount = 0,
|
|
|
|
discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),
|
2017-12-16 21:28:18 +01:00
|
|
|
albumId = "618", artistId = "362", type = "music")
|
2017-08-20 22:04:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|