From 34b49f67a23d7f70aaf5f5565ef7452385279ad9 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 17 Aug 2017 23:00:51 +0200 Subject: [PATCH] Add unstar request. Signed-off-by: Yahor Berdnikau --- .../api/subsonic/SubsonicApiUnstarTest.kt | 61 +++++++++++++++++++ .../api/subsonic/SubsonicAPIDefinition.kt | 5 ++ 2 files changed, 66 insertions(+) create mode 100644 subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiUnstarTest.kt diff --git a/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiUnstarTest.kt b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiUnstarTest.kt new file mode 100644 index 00000000..e183bc0e --- /dev/null +++ b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiUnstarTest.kt @@ -0,0 +1,61 @@ +package org.moire.ultrasonic.api.subsonic + +import org.amshove.kluent.`should be` +import org.amshove.kluent.`should contain` +import org.junit.Test +import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse + +/** + * Intergration test for [SubsonicAPIClient] for unstar call. + */ +class SubsonicApiUnstarTest : SubsonicAPIClientTest() { + @Test + fun `Should parse ok response`() { + mockWebServerRule.enqueueResponse("ping_ok.json") + + val response = client.api.unstar().execute() + + assertResponseSuccessful(response) + response.body().status `should be` SubsonicResponse.Status.OK + } + + @Test + fun `Should parse error response`() { + checkErrorCallParsed(mockWebServerRule, { + client.api.unstar().execute() + }) + } + + @Test + fun `Should pass id param`() { + mockWebServerRule.enqueueResponse("ping_ok.json") + val id = 545L + client.api.unstar(id = id).execute() + + val request = mockWebServerRule.mockWebServer.takeRequest() + + request.requestLine `should contain` "id=$id" + } + + @Test + fun `Should pass artistId param`() { + mockWebServerRule.enqueueResponse("ping_ok.json") + val artistId = 644L + client.api.unstar(artistId = artistId).execute() + + val request = mockWebServerRule.mockWebServer.takeRequest() + + request.requestLine `should contain` "artistId=$artistId" + } + + @Test + fun `Should pass albumId param`() { + mockWebServerRule.enqueueResponse("ping_ok.json") + val albumId = 3344L + client.api.unstar(albumId = albumId).execute() + + val request = mockWebServerRule.mockWebServer.takeRequest() + + request.requestLine `should contain` "albumId=$albumId" + } +} diff --git a/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIDefinition.kt b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIDefinition.kt index 6e59d62e..95e85307 100644 --- a/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIDefinition.kt +++ b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIDefinition.kt @@ -39,4 +39,9 @@ interface SubsonicAPIDefinition { fun star(@Query("id") id: Long? = null, @Query("albumId") albumId: Long? = null, @Query("artistId") artistId: Long? = null): Call + + @GET("unstar.view") + fun unstar(@Query("id") id: Long? = null, + @Query("albumId") albumId: Long? = null, + @Query("artistId") artistId: Long? = null): Call }