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