mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-18 04:30:48 +01:00
commit
19f5dde397
@ -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)
|
@ -70,6 +70,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;
|
||||
@ -714,21 +715,16 @@ public class RESTMusicService implements MusicService
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult getStarred(Context context, ProgressListener progressListener) throws Exception
|
||||
{
|
||||
checkServerVersion(context, "1.8", "Starred albums not supported.");
|
||||
@Override
|
||||
public SearchResult getStarred(Context context,
|
||||
ProgressListener progressListener) throws Exception {
|
||||
updateProgressListener(progressListener, R.string.parser_reading);
|
||||
Response<GetStarredResponse> response = subsonicAPIClient.getApi()
|
||||
.getStarred(null).execute();
|
||||
checkResponseSuccessful(response);
|
||||
|
||||
Reader reader = getReader(context, progressListener, "getStarred", null);
|
||||
try
|
||||
{
|
||||
return new SearchResult2Parser(context).parse(reader, progressListener, false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.close(reader);
|
||||
}
|
||||
}
|
||||
return APISearchConverter.toDomainEntity(response.body().getStarred());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult getStarred2(Context context, ProgressListener progressListener) throws Exception
|
||||
|
Loading…
x
Reference in New Issue
Block a user