diff --git a/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiGetStarredTest.kt b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiGetStarredTest.kt new file mode 100644 index 00000000..589f0fff --- /dev/null +++ b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicApiGetStarredTest.kt @@ -0,0 +1,47 @@ +package org.moire.ultrasonic.api.subsonic + +import org.amshove.kluent.`should equal to` +import org.amshove.kluent.`should equal` +import org.junit.Test +import org.moire.ultrasonic.api.subsonic.models.Artist +import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult + +/** + * Integration test for [SubsonicAPIClient] for getStarred call. + */ +class SubsonicApiGetStarredTest : SubsonicAPIClientTest() { + @Test + fun `Should handle error response`() { + val response = checkErrorCallParsed(mockWebServerRule) { + client.api.getStarred().execute() + } + + response.starred `should equal` SearchTwoResult() + } + + @Test + fun `Should handle ok reponse`() { + mockWebServerRule.enqueueResponse("get_starred_ok.json") + + val response = client.api.getStarred().execute() + + assertResponseSuccessful(response) + with(response.body().starred) { + albumList `should equal` emptyList() + artistList.size `should equal to` 1 + artistList[0] `should equal` Artist(id = 364, name = "Parov Stelar", + starred = parseDate("2017-08-12T18:32:58.768Z")) + songList `should equal` emptyList() + } + } + + @Test + fun `Should pass music folder id in request param`() { + val musicFolderId = 441L + + mockWebServerRule.assertRequestParam(responseResourceName = "get_starred_ok.json", + expectedParam = "musicFolderId=$musicFolderId") { + client.api.getStarred(musicFolderId = musicFolderId).execute() + } + } +} diff --git a/subsonic-api/src/integrationTest/resources/get_starred_ok.json b/subsonic-api/src/integrationTest/resources/get_starred_ok.json new file mode 100644 index 00000000..4adab54d --- /dev/null +++ b/subsonic-api/src/integrationTest/resources/get_starred_ok.json @@ -0,0 +1,13 @@ +{ + "subsonic-response" : { + "status" : "ok", + "version" : "1.15.0", + "starred" : { + "artist" : [ { + "id" : "364", + "name" : "Parov Stelar", + "starred" : "2017-08-12T18:32:58.768Z" + } ] + } + } +} \ No newline at end of file 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 6be4263b..a9edabf3 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 @@ -13,6 +13,7 @@ import org.moire.ultrasonic.api.subsonic.response.GetPlaylistResponse import org.moire.ultrasonic.api.subsonic.response.GetPlaylistsResponse import org.moire.ultrasonic.api.subsonic.response.GetPodcastsResponse import org.moire.ultrasonic.api.subsonic.response.GetRandomSongsResponse +import org.moire.ultrasonic.api.subsonic.response.GetStarredResponse import org.moire.ultrasonic.api.subsonic.response.LicenseResponse import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse import org.moire.ultrasonic.api.subsonic.response.SearchResponse @@ -152,4 +153,7 @@ interface SubsonicAPIDefinition { @Query("fromYear") fromYear: Int? = null, @Query("toYear") toYear: Int? = null, @Query("musicFolderId") musicFolderId: Long? = null): Call + + @GET("getStarred.view") + fun getStarred(@Query("musicFolderId") musicFolderId: Long? = null): Call } diff --git a/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/response/GetStarredResponse.kt b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/response/GetStarredResponse.kt new file mode 100644 index 00000000..dc4e59eb --- /dev/null +++ b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/response/GetStarredResponse.kt @@ -0,0 +1,11 @@ +package org.moire.ultrasonic.api.subsonic.response + +import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions +import org.moire.ultrasonic.api.subsonic.SubsonicError +import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult + +class GetStarredResponse(status: Status, + version: SubsonicAPIVersions, + error: SubsonicError?, + val starred: SearchTwoResult = SearchTwoResult()) + : SubsonicResponse(status, version, error)