Add createPlaylist api call.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-09-02 20:27:32 +02:00
parent f55f19a3b8
commit bb64b9e3ca
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package org.moire.ultrasonic.api.subsonic
import org.junit.Test
/**
* Integration test for [SubsonicAPIClient] for createPlaylist call.
*/
class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.createPlaylist().execute()
}
}
@Test
fun `Should hanlde ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.createPlaylist().execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id param in request`() {
val id = 56L
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
client.api.createPlaylist(id = id).execute()
}
}
@Test
fun `Should pass name param in request`() {
val name = "some-name"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "name=$name") {
client.api.createPlaylist(name = name).execute()
}
}
@Test
fun `Should pass song id param in request`() {
val songId = listOf(4410L, 852L)
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songId=${songId[0]}&songId=${songId[1]}") {
client.api.createPlaylist(songIds = songId).execute()
}
}
}

View File

@ -91,4 +91,9 @@ interface SubsonicAPIDefinition {
@GET("getPlaylists.view")
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
@GET("createPlaylist.view")
fun createPlaylist(@Query("playlistId") id: Long? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse>
}