1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-02-18 20:50:37 +01:00

Merge pull request #43 from ultrasonic/add-delete-playlist

Add delete playlist
This commit is contained in:
Yahor Berdnikau 2017-09-02 21:16:12 +02:00 committed by GitHub
commit 02902023da
3 changed files with 48 additions and 13 deletions

View File

@ -0,0 +1,34 @@
package org.moire.ultrasonic.api.subsonic
import org.junit.Test
/**
* Instrumentation test for [SubsonicAPIClient] for deletePlaylist call.
*/
class SubsonicApiDeletePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deletePlaylist(10).execute()
}
}
@Test
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deletePlaylist(10).execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id param in request`() {
val id = 534L
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
client.api.deletePlaylist(id).execute()
}
}
}

View File

@ -96,4 +96,7 @@ interface SubsonicAPIDefinition {
fun createPlaylist(@Query("playlistId") id: Long? = null, fun createPlaylist(@Query("playlistId") id: Long? = null,
@Query("name") name: String? = null, @Query("name") name: String? = null,
@Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse> @Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse>
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: Long): Call<SubsonicResponse>
} }

View File

@ -593,19 +593,17 @@ public class RESTMusicService implements MusicService
checkResponseSuccessful(response); checkResponseSuccessful(response);
} }
@Override @Override
public void deletePlaylist(String id, Context context, ProgressListener progressListener) throws Exception public void deletePlaylist(String id,
{ Context context,
Reader reader = getReader(context, progressListener, "deletePlaylist", null, "id", id); ProgressListener progressListener) throws Exception {
try Long pId = id == null ? null : Long.valueOf(id);
{
new ErrorParser(context).parse(reader); updateProgressListener(progressListener, R.string.parser_reading);
} Response<SubsonicResponse> response = subsonicAPIClient.getApi()
finally .deletePlaylist(pId).execute();
{ checkResponseSuccessful(response);
Util.close(reader); }
}
}
@Override @Override
public void updatePlaylist(String id, String name, String comment, boolean pub, Context context, ProgressListener progressListener) throws Exception public void updatePlaylist(String id, String name, String comment, boolean pub, Context context, ProgressListener progressListener) throws Exception