2017-08-30 22:41:20 +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-30 22:41:20 +02:00
|
|
|
import org.amshove.kluent.`should equal`
|
|
|
|
import org.amshove.kluent.`should not be`
|
|
|
|
import org.junit.Test
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Playlist
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Integration test for [SubsonicAPIClient] for getPlaylists call.
|
|
|
|
*/
|
|
|
|
class SubsonicApiGetPlaylistsTest : SubsonicAPIClientTest() {
|
|
|
|
@Test
|
|
|
|
fun `Should parse error call`() {
|
|
|
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
|
|
|
client.api.getPlaylists().execute()
|
|
|
|
}
|
|
|
|
|
|
|
|
response.playlists `should not be` null
|
|
|
|
response.playlists `should equal` emptyList()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should parse ok response`() {
|
|
|
|
mockWebServerRule.enqueueResponse("get_playlists_ok.json")
|
|
|
|
|
|
|
|
val response = client.api.getPlaylists().execute()
|
|
|
|
|
|
|
|
assertResponseSuccessful(response)
|
2018-03-24 18:57:18 +01:00
|
|
|
with(response.body()!!.playlists) {
|
2018-03-24 19:30:03 +01:00
|
|
|
size `should be equal to` 1
|
2017-12-16 20:47:00 +01:00
|
|
|
this[0] `should equal` Playlist(id = "0", name = "Aug 27, 2017 11:17 AM",
|
2017-08-30 22:41:20 +02:00
|
|
|
owner = "admin", public = false, songCount = 16, duration = 3573,
|
|
|
|
comment = "Some comment",
|
|
|
|
created = parseDate("2017-08-27T11:17:26.216Z"),
|
|
|
|
changed = parseDate("2017-08-27T11:17:26.218Z"),
|
|
|
|
coverArt = "pl-0")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should pass username as a parameter`() {
|
|
|
|
val username = "SomeUsername"
|
|
|
|
|
|
|
|
mockWebServerRule.assertRequestParam(responseResourceName = "get_playlists_ok.json",
|
|
|
|
expectedParam = "username=$username") {
|
|
|
|
client.api.getPlaylists(username = username).execute()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|