Add scrobble call.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-09-04 21:20:22 +02:00
parent 7143dc4db1
commit 9892805517
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package org.moire.ultrasonic.api.subsonic
import org.junit.Test
import java.util.Calendar
/**
* Integration test for [SubsonicAPIClient] for scrobble call.
*/
class SubsonicApiScrobbleTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.scrobble("id").execute()
}
}
@Test
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.scrobble("id").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id param in request`() {
val id = "some-id"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
client.api.scrobble(id = id).execute()
}
}
@Test
fun `Should pass time param in request`() {
val time = Calendar.getInstance().timeInMillis
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "time=$time") {
client.api.scrobble(id = "some-id", time = time).execute()
}
}
@Test
fun `Should pass submission param in request`() {
val submission = false
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "submission=$submission") {
client.api.scrobble(id = "some-id", submission = submission).execute()
}
}
}

View File

@ -118,4 +118,9 @@ interface SubsonicAPIDefinition {
@GET("getLyrics.view")
fun getLyrics(@Query("artist") artist: String? = null,
@Query("title") title: String? = null): Call<GetLyricsResponse>
@GET("scrobble.view")
fun scrobble(@Query("id") id: String,
@Query("time") time: Long? = null,
@Query("submission") submission: Boolean? = null): Call<SubsonicResponse>
}