Add getStarred call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
af72475be5
commit
bad5cf5a9a
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
} ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<GetRandomSongsResponse>
|
||||
|
||||
@GET("getStarred.view")
|
||||
fun getStarred(@Query("musicFolderId") musicFolderId: Long? = null): Call<GetStarredResponse>
|
||||
}
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue