Merge pull request #94 from ultrasonic/bug/entities-ids

Bug/entities ids
This commit is contained in:
Yahor Berdnikau 2017-12-16 22:22:54 +01:00 committed by GitHub
commit 4715deb159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 299 additions and 329 deletions

View File

@ -9,7 +9,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.createBookmark(1, 1).execute()
client.api.createBookmark("1", 1).execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.createBookmark(213, 123213L).execute()
val response = client.api.createBookmark("213", 123213L).execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 544
val id = "544"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.createBookmark(id = id, position = 123).execute()
@ -36,7 +36,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
val position = 4412333L
mockWebServerRule.assertRequestParam(expectedParam = "position=$position") {
client.api.createBookmark(id = 12, position = position).execute()
client.api.createBookmark(id = "12", position = position).execute()
}
}
@ -45,7 +45,7 @@ class SubsonicApiCreateBookmarkTest : SubsonicAPIClientTest() {
val comment = "some-comment"
mockWebServerRule.assertRequestParam(expectedParam = "comment=$comment") {
client.api.createBookmark(id = 1, position = 1, comment = comment).execute()
client.api.createBookmark(id = "1", position = 1, comment = comment).execute()
}
}
}

View File

@ -24,7 +24,7 @@ class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param in request`() {
val id = 56L
val id = "56"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
@ -44,7 +44,7 @@ class SubsonicApiCreatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass song id param in request`() {
val songId = listOf(4410L, 852L)
val songId = listOf("4410", "852")
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songId=${songId[0]}&songId=${songId[1]}") {

View File

@ -28,7 +28,7 @@ class SubsonicApiCreateShareTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
response.body().shares.size `should equal to` 1
with(response.body().shares[0]) {
id `should equal to` 0
id `should equal to` "0"
url `should equal to` "https://subsonic.com/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1NiJ9." +
"eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8hJ692" +
"UxorHdHWFU2RB-fMCmCA4IJ_dTw"
@ -39,13 +39,13 @@ class SubsonicApiCreateShareTest : SubsonicAPIClientTest() {
description `should equal to` "Awesome link!"
visitCount `should equal to` 0
items.size `should equal to` 1
items[0] `should equal` MusicDirectoryChild(id = 4212, parent = 4186, isDir = false,
items[0] `should equal` MusicDirectoryChild(id = "4212", parent = "4186", isDir = false,
title = "Heaven Knows", album = "Going to Hell", artist = "The Pretty Reckless",
track = 3, year = 2014, genre = "Hard Rock", coverArt = "4186", size = 9025090,
contentType = "audio/mpeg", suffix = "mp3", duration = 225, bitRate = 320,
path = "The Pretty Reckless/Going to Hell/03 Heaven Knows.mp3", isVideo = false,
playCount = 2, discNumber = 1, created = parseDate("2016-10-23T21:30:40.000Z"),
albumId = 388, artistId = 238, type = "music")
albumId = "388", artistId = "238", type = "music")
}
}

View File

@ -9,7 +9,7 @@ class SubsonicApiDeleteBookmarkTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deleteBookmark(1).execute()
client.api.deleteBookmark("1").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeleteBookmarkTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deleteBookmark(1).execute()
val response = client.api.deleteBookmark("1").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 233
val id = "233"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.deleteBookmark(id).execute()

View File

@ -9,7 +9,7 @@ class SubsonicApiDeletePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deletePlaylist(10).execute()
client.api.deletePlaylist("10").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeletePlaylistTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deletePlaylist(10).execute()
val response = client.api.deletePlaylist("10").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id param in request`() {
val id = 534L
val id = "534"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {

View File

@ -9,7 +9,7 @@ class SubsonicApiDeleteShareTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.deleteShare(123).execute()
client.api.deleteShare("123").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiDeleteShareTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.deleteShare(12).execute()
val response = client.api.deleteShare("12").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 224L
val id = "224"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.deleteShare(id).execute()

View File

@ -30,12 +30,12 @@ class SubsonicApiGetAlbumList2Test : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().albumList) {
this.size `should equal to` 2
this[0] `should equal` Album(id = 962, name = "Fury", artist = "Sick Puppies",
artistId = 473, coverArt = "al-962", songCount = 13, duration = 2591,
this[0] `should equal` Album(id = "962", name = "Fury", artist = "Sick Puppies",
artistId = "473", coverArt = "al-962", songCount = 13, duration = 2591,
created = parseDate("2017-09-02T17:34:51.000Z"), year = 2016,
genre = "Alternative Rock")
this[1] `should equal` Album(id = 961, name = "Endless Forms Most Beautiful",
artist = "Nightwish", artistId = 559, coverArt = "al-961", songCount = 22,
this[1] `should equal` Album(id = "961", name = "Endless Forms Most Beautiful",
artist = "Nightwish", artistId = "559", coverArt = "al-961", songCount = 22,
duration = 9469, created = parseDate("2017-09-02T16:22:47.000Z"),
year = 2015, genre = "Symphonic Metal")
}
@ -103,7 +103,7 @@ class SubsonicApiGetAlbumList2Test : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 9422L
val musicFolderId = "9422"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_list_2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -29,7 +29,7 @@ class SubsonicApiGetAlbumListRequestTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().albumList) {
size `should equal to` 2
this[1] `should equal` MusicDirectoryChild(id = 9997, parent = 9996, isDir = true,
this[1] `should equal` MusicDirectoryChild(id = "9997", parent = "9996", isDir = true,
title = "Endless Forms Most Beautiful", album = "Endless Forms Most Beautiful",
artist = "Nightwish", year = 2015, genre = "Symphonic Metal",
coverArt = "9997", playCount = 11,
@ -99,7 +99,7 @@ class SubsonicApiGetAlbumListRequestTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request params`() {
val folderId = 545L
val folderId = "545"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_list_ok.json",
expectedParam = "musicFolderId=$folderId") {

View File

@ -14,7 +14,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error responce`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getAlbum(56L).execute()
client.api.getAlbum("56").execute()
}
response.album `should not be` null
@ -23,7 +23,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
@Test
fun `Should add id to request params`() {
val id = 76L
val id = "76"
mockWebServerRule.assertRequestParam(responseResourceName = "get_album_ok.json",
expectedParam = "id=$id") {
@ -35,14 +35,14 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_album_ok.json")
val response = client.api.getAlbum(512L).execute()
val response = client.api.getAlbum("512").execute()
assertResponseSuccessful(response)
with(response.body().album) {
id `should equal to` 618L
id `should equal to` "618"
name `should equal to` "Black Ice"
artist `should equal to` "AC/DC"
artistId `should equal to` 362L
artistId `should equal to` "362"
coverArt `should equal to` "al-618"
songCount `should equal to` 15
duration `should equal to` 3331
@ -50,20 +50,20 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
year `should equal to` 2008
genre `should equal to` "Hard Rock"
songList.size `should equal to` 15
songList[0] `should equal` MusicDirectoryChild(id = 6491L, parent = 6475L, isDir = false,
songList[0] `should equal` MusicDirectoryChild(id = "6491", parent = "6475", isDir = false,
title = "Rock 'n' Roll Train", album = "Black Ice", artist = "AC/DC",
track = 1, year = 2008, genre = "Hard Rock", coverArt = "6475", size = 7205451,
contentType = "audio/mpeg", suffix = "mp3", duration = 261, bitRate = 219,
path = "AC_DC/Black Ice/01 Rock 'n' Roll Train.mp3", isVideo = false,
playCount = 0, discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),
albumId = 618L, artistId = 362L, type = "music")
songList[5] `should equal` MusicDirectoryChild(id = 6492L, parent = 6475L, isDir = false,
albumId = "618", artistId = "362", type = "music")
songList[5] `should equal` MusicDirectoryChild(id = "6492", parent = "6475", isDir = false,
title = "Smash 'n' Grab", album = "Black Ice", artist = "AC/DC", track = 6,
year = 2008, genre = "Hard Rock", coverArt = "6475", size = 6697204,
contentType = "audio/mpeg", suffix = "mp3", duration = 246, bitRate = 216,
path = "AC_DC/Black Ice/06 Smash 'n' Grab.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),
albumId = 618L, artistId = 362L, type = "music")
albumId = "618", artistId = "362", type = "music")
}
}
}

View File

@ -14,7 +14,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error call`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getArtist(101L).execute()
client.api.getArtist("101").execute()
}
response.artist `should not be` null
@ -23,7 +23,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param in request`() {
val id = 929L
val id = "929"
mockWebServerRule.assertRequestParam(responseResourceName = "get_artist_ok.json",
expectedParam = "id=$id") {
@ -35,21 +35,21 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_artist_ok.json")
val response = client.api.getArtist(100L).execute()
val response = client.api.getArtist("100").execute()
assertResponseSuccessful(response)
with(response.body().artist) {
id `should equal to` 362L
id `should equal to` "362"
name `should equal to` "AC/DC"
coverArt `should equal to` "ar-362"
albumCount `should equal to` 2
albumsList.size `should equal to` 2
albumsList[0] `should equal` Album(id = 618L, name = "Black Ice", artist = "AC/DC",
artistId = 362L, coverArt = "al-618", songCount = 15, duration = 3331,
albumsList[0] `should equal` Album(id = "618", name = "Black Ice", artist = "AC/DC",
artistId = "362", coverArt = "al-618", songCount = 15, duration = 3331,
created = parseDate("2016-10-23T15:31:22.000Z"),
year = 2008, genre = "Hard Rock")
albumsList[1] `should equal` Album(id = 617L, name = "Rock or Bust", artist = "AC/DC",
artistId = 362L, coverArt = "al-617", songCount = 11, duration = 2095,
albumsList[1] `should equal` Album(id = "617", name = "Rock or Bust", artist = "AC/DC",
artistId = "362", coverArt = "al-617", songCount = 11, duration = 2095,
created = parseDate("2016-10-23T15:31:23.000Z"),
year = 2014, genre = "Hard Rock")
}

View File

@ -36,12 +36,12 @@ class SubsonicApiGetArtistsTest : SubsonicAPIClientTest() {
indexList.size `should equal to` 2
indexList `should equal` listOf(
Index(name = "A", artists = listOf(
Artist(id = 362L, name = "AC/DC", coverArt = "ar-362", albumCount = 2),
Artist(id = 254L, name = "Acceptance", coverArt = "ar-254", albumCount = 1)
Artist(id = "362", name = "AC/DC", coverArt = "ar-362", albumCount = 2),
Artist(id = "254", name = "Acceptance", coverArt = "ar-254", albumCount = 1)
)),
Index(name = "T", artists = listOf(
Artist(id = 516L, name = "Tangerine Dream", coverArt = "ar-516", albumCount = 1),
Artist(id = 242L, name = "Taproot", coverArt = "ar-242", albumCount = 2)
Artist(id = "516", name = "Tangerine Dream", coverArt = "ar-516", albumCount = 1),
Artist(id = "242", name = "Taproot", coverArt = "ar-242", albumCount = 2)
))
)
}
@ -50,7 +50,7 @@ class SubsonicApiGetArtistsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass param on query for get artists call`() {
mockWebServerRule.enqueueResponse("get_artists_ok.json")
val musicFolderId = 101L
val musicFolderId = "101"
mockWebServerRule.assertRequestParam(responseResourceName = "get_artists_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -32,7 +32,7 @@ class SubsonicApiGetBookmarksTest : SubsonicAPIClientTest() {
comment `should equal to` "Look at this"
created `should equal` parseDate("2017-11-18T15:22:22.144Z")
changed `should equal` parseDate("2017-11-18T15:22:22.144Z")
entry `should equal` MusicDirectoryChild(id = 10349, parent = 10342,
entry `should equal` MusicDirectoryChild(id = "10349", parent = "10342",
isDir = false, title = "Amerika", album = "Home of the Strange",
artist = "Young the Giant", track = 1, year = 2016, genre = "Indie Rock",
coverArt = "10342", size = 9628673, contentType = "audio/mpeg",
@ -40,7 +40,7 @@ class SubsonicApiGetBookmarksTest : SubsonicAPIClientTest() {
path = "Young the Giant/Home of the Strange/01 Amerika.mp3",
isVideo = false, playCount = 2, discNumber = 1,
created = parseDate("2017-11-01T17:46:52.000Z"),
albumId = 984, artistId = 571, type = "music")
albumId = "984", artistId = "571", type = "music")
}
}
}

View File

@ -23,18 +23,18 @@ class SubsonicApiGetIndexesTest : SubsonicAPIClientTest() {
lastModified `should equal` 1491069027523
ignoredArticles `should equal` "The El La Los Las Le Les"
shortcutList `should equal` listOf(
Artist(id = 889L, name = "podcasts"),
Artist(id = 890L, name = "audiobooks")
Artist(id = "889", name = "podcasts"),
Artist(id = "890", name = "audiobooks")
)
indexList `should equal` mutableListOf(
Index("A", listOf(
Artist(id = 50L, name = "Ace Of Base",
Artist(id = "50", name = "Ace Of Base",
starred = parseDate("2017-04-02T20:16:29.815Z")),
Artist(id = 379L, name = "A Perfect Circle")
Artist(id = "379", name = "A Perfect Circle")
)),
Index("H", listOf(
Artist(id = 299, name = "Haddaway"),
Artist(id = 297, name = "Halestorm")
Artist(id = "299", name = "Haddaway"),
Artist(id = "297", name = "Halestorm")
))
)
}
@ -42,7 +42,7 @@ class SubsonicApiGetIndexesTest : SubsonicAPIClientTest() {
@Test
fun `Should add music folder id as a query param for getIndexes api call`() {
val musicFolderId = 9L
val musicFolderId = "9"
mockWebServerRule.assertRequestParam(responseResourceName = "get_indexes_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -15,7 +15,7 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
@Test
fun `Should parse getMusicDirectory error response`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getMusicDirectory(1).execute()
client.api.getMusicDirectory("1").execute()
}
response.musicDirectory `should not be` null
@ -24,7 +24,7 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
@Test
fun `GetMusicDirectory should add directory id to query params`() {
val directoryId = 124L
val directoryId = "124"
mockWebServerRule.assertRequestParam(responseResourceName = "get_music_directory_ok.json",
expectedParam = "id=$directoryId") {
@ -36,34 +36,34 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
fun `Should parse get music directory ok response`() {
mockWebServerRule.enqueueResponse("get_music_directory_ok.json")
val response = client.api.getMusicDirectory(1).execute()
val response = client.api.getMusicDirectory("1").execute()
assertResponseSuccessful(response)
response.body().musicDirectory `should not be` null
with(response.body().musicDirectory) {
id `should equal to` 4836L
parent `should equal to` 300L
id `should equal to` "4836"
parent `should equal to` "300"
name `should equal` "12 Stones"
userRating `should equal to` 5
averageRating `should equal to` 5.0f
starred `should equal` null
playCount `should equal to` 1
childList.size `should be` 2
childList[0] `should equal` MusicDirectoryChild(id = 4844L, parent = 4836L, isDir = false,
childList[0] `should equal` MusicDirectoryChild(id = "4844", parent = "4836", isDir = false,
title = "Crash", album = "12 Stones", artist = "12 Stones", track = 1, year = 2002,
genre = "Alternative Rock", coverArt = "4836", size = 5348318L,
contentType = "audio/mpeg", suffix = "mp3", duration = 222, bitRate = 192,
path = "12 Stones/12 Stones/01 Crash.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:19:10.000Z"),
albumId = 454L, artistId = 288L, type = "music")
childList[1] `should equal` MusicDirectoryChild(id = 4845L, parent = 4836L, isDir = false,
albumId = "454", artistId = "288", type = "music")
childList[1] `should equal` MusicDirectoryChild(id = "4845", parent = "4836", isDir = false,
title = "Broken", album = "12 Stones", artist = "12 Stones", track = 2, year = 2002,
genre = "Alternative Rock", coverArt = "4836", size = 4309043L,
contentType = "audio/mpeg", suffix = "mp3", duration = 179, bitRate = 192,
path = "12 Stones/12 Stones/02 Broken.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:19:09.000Z"),
albumId = 454L, artistId = 288L, type = "music")
albumId = "454", artistId = "288", type = "music")
}
}
}

View File

@ -17,7 +17,9 @@ class SubsonicApiGetMusicFoldersTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body()) {
assertBaseResponseOk()
musicFolders `should equal` listOf(MusicFolder(0, "Music"), MusicFolder(2, "Test"))
musicFolders `should equal` listOf(
MusicFolder("0", "Music"),
MusicFolder("2", "Test"))
}
}

View File

@ -14,7 +14,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should parse error response`() {
val response = checkErrorCallParsed(mockWebServerRule) {
client.api.getPlaylist(10).execute()
client.api.getPlaylist("10").execute()
}
response.playlist `should not be` null
@ -25,11 +25,11 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
fun `Should parse ok response`() {
mockWebServerRule.enqueueResponse("get_playlist_ok.json")
val response = client.api.getPlaylist(4).execute()
val response = client.api.getPlaylist("4").execute()
assertResponseSuccessful(response)
with(response.body().playlist) {
id `should equal to` 0
id `should equal to` "0"
name `should equal to` "Aug 27, 2017 11:17 AM"
owner `should equal to` "admin"
public `should equal to` false
@ -39,7 +39,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
changed `should equal` parseDate("2017-08-27T11:17:26.218Z")
coverArt `should equal to` "pl-0"
entriesList.size `should equal to` 2
entriesList[1] `should equal` MusicDirectoryChild(id = 4215, parent = 4186,
entriesList[1] `should equal` MusicDirectoryChild(id = "4215", parent = "4186",
isDir = false, title = "Going to Hell", album = "Going to Hell",
artist = "The Pretty Reckless", track = 2, year = 2014,
genre = "Hard Rock", coverArt = "4186", size = 11089627,
@ -47,13 +47,13 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
path = "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3",
isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T21:30:41.000Z"),
albumId = 388, artistId = 238, type = "music")
albumId = "388", artistId = "238", type = "music")
}
}
@Test
fun `Should pass id as request param`() {
val playlistId = 453L
val playlistId = "453"
mockWebServerRule.assertRequestParam(responseResourceName = "get_playlist_ok.json",
expectedParam = "id=$playlistId") {

View File

@ -29,7 +29,7 @@ class SubsonicApiGetPlaylistsTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().playlists) {
size `should equal to` 1
this[0] `should equal` Playlist(id = 0, name = "Aug 27, 2017 11:17 AM",
this[0] `should equal` Playlist(id = "0", name = "Aug 27, 2017 11:17 AM",
owner = "admin", public = false, songCount = 16, duration = 3573,
comment = "Some comment",
created = parseDate("2017-08-27T11:17:26.216Z"),

View File

@ -30,7 +30,7 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
val podcastChannelsList = response.body().podcastChannels
podcastChannelsList.size `should equal to` 1
with(podcastChannelsList[0]) {
id `should equal to` 2
id `should equal to` "2"
url `should equal to` "http://feeds.codenewbie.org/cnpodcast.xml"
title `should equal to` "CodeNewbie"
description `should equal to` "Stories and interviews from people on their coding journey."
@ -39,13 +39,13 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
status `should equal to` "completed"
errorMessage `should equal to` ""
episodeList.size `should equal to` 10
episodeList[0] `should equal` MusicDirectoryChild(id = 148, parent = 9959, isDir = false,
episodeList[0] `should equal` MusicDirectoryChild(id = "148", parent = "9959", isDir = false,
title = "S1:EP3 How to teach yourself computer science (Vaidehi Joshi)",
album = "CodeNewbie", artist = "podcasts", coverArt = "9959",
size = 38274221, contentType = "audio/mpeg", suffix = "mp3",
duration = 2397, bitRate = 128, isVideo = false, playCount = 0,
created = parseDate("2017-08-30T09:33:39.000Z"), type = "podcast",
streamId = 9982, channelId = 2,
streamId = "9982", channelId = "2",
description = "Vaidehi decided to take on a year-long challenge. " +
"She'd pick a computer science topic every week, do tons of research " +
"and write a technical blog post explaining it in simple terms and " +
@ -72,7 +72,7 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id in request param`() {
val id = 249L
val id = "249"
mockWebServerRule.assertRequestParam(responseResourceName = "get_podcasts_ok.json",
expectedParam = "id=$id") {

View File

@ -27,14 +27,14 @@ class SubsonicApiGetRandomSongsTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().songsList) {
size `should equal to` 3
this[1] `should equal` MusicDirectoryChild(id = 3061, parent = 3050, isDir = false,
this[1] `should equal` MusicDirectoryChild(id = "3061", parent = "3050", isDir = false,
title = "Sure as Hell", album = "Who Are You Now?", artist = "This Providence",
track = 1, year = 2009, genre = "Indie Rock", coverArt = "3050",
size = 1969692, contentType = "audio/mpeg", suffix = "mp3", duration = 110,
bitRate = 142, path = "This Providence/Who Are You Now_/01 Sure as Hell.mp3",
isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T21:32:46.000Z"), albumId = 272,
artistId = 152, type = "music")
created = parseDate("2016-10-23T21:32:46.000Z"), albumId = "272",
artistId = "152", type = "music")
}
}
@ -80,7 +80,7 @@ class SubsonicApiGetRandomSongsTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 4919L
val musicFolderId = "4919"
mockWebServerRule.assertRequestParam(responseResourceName = "get_random_songs_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiGetSharesTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
response.body().shares.size `should equal to` 1
with(response.body().shares[0]) {
id `should equal to` 0
id `should equal to` "0"
url `should equal to` "https://subsonic.com/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1" +
"NiJ9.eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8" +
"hJ692UxorHdHWFU2RB-fMCmCA4IJ_dTw"
@ -38,13 +38,13 @@ class SubsonicApiGetSharesTest : SubsonicAPIClientTest() {
visitCount `should equal to` 0
description `should equal to` "Awesome link!"
items.size `should equal to` 1
items[0] `should equal` MusicDirectoryChild(id = 4212, parent = 4186, isDir = false,
items[0] `should equal` MusicDirectoryChild(id = "4212", parent = "4186", isDir = false,
title = "Heaven Knows", album = "Going to Hell", artist = "The Pretty Reckless",
track = 3, year = 2014, genre = "Hard Rock", coverArt = "4186", size = 9025090,
contentType = "audio/mpeg", suffix = "mp3", duration = 225, bitRate = 320,
path = "The Pretty Reckless/Going to Hell/03 Heaven Knows.mp3", isVideo = false,
playCount = 2, discNumber = 1, created = parseDate("2016-10-23T21:30:40.000Z"),
albumId = 388, artistId = 238, type = "music")
albumId = "388", artistId = "238", type = "music")
}
}
}

View File

@ -27,21 +27,21 @@ class SubsonicApiGetSongsByGenreTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
response.body().songsList.size `should equal to` 2
with(response.body().songsList) {
this[0] `should equal` MusicDirectoryChild(id = 575, parent = 576, isDir = false,
this[0] `should equal` MusicDirectoryChild(id = "575", parent = "576", isDir = false,
title = "Time Machine (Vadim Zhukov Remix)", album = "668",
artist = "Tasadi", year = 2008, genre = "Trance", size = 22467672,
contentType = "audio/mpeg", suffix = "mp3", duration = 561, bitRate = 320,
path = "Tasadi/668/00 Time Machine (Vadim Zhukov Remix).mp3",
isVideo = false, playCount = 0, created = parseDate("2016-10-23T21:58:29.000Z"),
albumId = 0, artistId = 0, type = "music")
this[1] `should equal` MusicDirectoryChild(id = 621, parent = 622, isDir = false,
albumId = "0", artistId = "0", type = "music")
this[1] `should equal` MusicDirectoryChild(id = "621", parent = "622", isDir = false,
title = "My Heart (Vadim Zhukov Remix)", album = "668",
artist = "DJ Polyakov PPK Feat Kate Cameron", year = 2009, genre = "Trance",
size = 26805932, contentType = "audio/mpeg", suffix = "mp3", duration = 670,
bitRate = 320,
path = "DJ Polyakov PPK Feat Kate Cameron/668/00 My Heart (Vadim Zhukov Remix).mp3",
isVideo = false, playCount = 2, created = parseDate("2016-10-23T21:58:29.000Z"),
albumId = 5, artistId = 4, type = "music")
albumId = "5", artistId = "4", type = "music")
}
}
@ -73,7 +73,7 @@ class SubsonicApiGetSongsByGenreTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 1010L
val musicFolderId = "1010"
mockWebServerRule.assertRequestParam(expectedParam = "musicFolderId=$musicFolderId") {
client.api.getSongsByGenre("Trance", musicFolderId = musicFolderId).execute()

View File

@ -30,7 +30,7 @@ class SubsonicApiGetStarred2Test : SubsonicAPIClientTest() {
with(response.body().starred2) {
albumList `should equal` emptyList()
artistList.size `should equal to` 1
artistList[0] `should equal` Artist(id = 364, name = "Parov Stelar",
artistList[0] `should equal` Artist(id = "364", name = "Parov Stelar",
starred = parseDate("2017-08-12T18:32:58.768Z"))
songList `should equal` emptyList()
}
@ -38,7 +38,7 @@ class SubsonicApiGetStarred2Test : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 441L
val musicFolderId = "441"
mockWebServerRule.assertRequestParam(responseResourceName = "get_starred_2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -29,7 +29,7 @@ class SubsonicApiGetStarredTest : SubsonicAPIClientTest() {
with(response.body().starred) {
albumList `should equal` emptyList()
artistList.size `should equal to` 1
artistList[0] `should equal` Artist(id = 364, name = "Parov Stelar",
artistList[0] `should equal` Artist(id = "364", name = "Parov Stelar",
starred = parseDate("2017-08-12T18:32:58.768Z"))
songList `should equal` emptyList()
}
@ -37,7 +37,7 @@ class SubsonicApiGetStarredTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 441L
val musicFolderId = "441"
mockWebServerRule.assertRequestParam(responseResourceName = "get_starred_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiGetVideosListTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().videosList) {
size `should equal to` 1
this[0] `should equal` MusicDirectoryChild(id = 10402, parent = 10401, isDir = false,
this[0] `should equal` MusicDirectoryChild(id = "10402", parent = "10401", isDir = false,
title = "MVI_0512", album = "Incoming", size = 21889646,
contentType = "video/avi", suffix = "avi", transcodedContentType = "video/x-flv",
transcodedSuffix = "flv", path = "Incoming/MVI_0512.avi", isVideo = true,

View File

@ -51,15 +51,15 @@ class SubsonicApiJukeboxControlTest : SubsonicAPIClientTest() {
gain `should equal to` 0.88f
position `should equal to` 2
playlistEntries.size `should equal to` 2
playlistEntries[1] `should equal` MusicDirectoryChild(id = 4215L, parent = 4186L,
playlistEntries[1] `should equal` MusicDirectoryChild(id = "4215", parent = "4186",
isDir = false, title = "Going to Hell", album = "Going to Hell",
artist = "The Pretty Reckless", track = 2, year = 2014, genre = "Hard Rock",
coverArt = "4186", size = 11089627, contentType = "audio/mpeg",
suffix = "mp3", duration = 277, bitRate = 320,
path = "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3", isVideo = false,
playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T21:30:41.000Z"), albumId = 388,
artistId = 238, type = "music")
created = parseDate("2016-10-23T21:30:41.000Z"), albumId = "388",
artistId = "238", type = "music")
}
}

View File

@ -33,7 +33,7 @@ class SubsonicApiSearchTest : SubsonicAPIClientTest() {
offset `should equal to` 10
totalHits `should equal to` 53
matchList.size `should equal to` 1
matchList[0] `should equal` MusicDirectoryChild(id = 5831L, parent = 5766L,
matchList[0] `should equal` MusicDirectoryChild(id = "5831", parent = "5766",
isDir = false, title = "You'll Be Under My Wheels",
album = "Need for Speed Most Wanted", artist = "The Prodigy",
track = 17, year = 2005, genre = "Rap", coverArt = "5766",
@ -41,8 +41,8 @@ class SubsonicApiSearchTest : SubsonicAPIClientTest() {
bitRate = 192,
path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels.mp3",
isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T20:09:02.000Z"), albumId = 568,
artistId = 505, type = "music")
created = parseDate("2016-10-23T20:09:02.000Z"), albumId = "568",
artistId = "505", type = "music")
}
}

View File

@ -32,23 +32,23 @@ class SubsonicApiSearchThreeTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().searchResult) {
artistList.size `should equal to` 1
artistList[0] `should equal` Artist(id = 505, name = "The Prodigy", coverArt = "ar-505",
artistList[0] `should equal` Artist(id = "505", name = "The Prodigy", coverArt = "ar-505",
albumCount = 5)
albumList.size `should equal to` 1
albumList[0] `should equal` Album(id = 855, name = "Always Outnumbered, Never Outgunned",
artist = "The Prodigy", artistId = 505, coverArt = "al-855", songCount = 12,
albumList[0] `should equal` Album(id = "855", name = "Always Outnumbered, Never Outgunned",
artist = "The Prodigy", artistId = "505", coverArt = "al-855", songCount = 12,
duration = 3313, created = parseDate("2016-10-23T20:57:27.000Z"),
year = 2004, genre = "Electronic")
songList.size `should equal to` 1
songList[0] `should equal` MusicDirectoryChild(id = 5831, parent = 5766, isDir = false,
songList[0] `should equal` MusicDirectoryChild(id = "5831", parent = "5766", isDir = false,
title = "You'll Be Under My Wheels", album = "Need for Speed Most Wanted",
artist = "The Prodigy", track = 17, year = 2005, genre = "Rap",
coverArt = "5766", size = 5607024, contentType = "audio/mpeg",
suffix = "mp3", duration = 233, bitRate = 192,
path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels.mp3",
isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T20:09:02.000Z"), albumId = 568,
artistId = 505, type = "music")
created = parseDate("2016-10-23T20:09:02.000Z"), albumId = "568",
artistId = "505", type = "music")
}
}
@ -113,7 +113,7 @@ class SubsonicApiSearchThreeTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id as request param`() {
val musicFolderId = 43L
val musicFolderId = "43"
mockWebServerRule.assertRequestParam(responseResourceName = "search3_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -31,15 +31,15 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response)
with(response.body().searchResult) {
artistList.size `should equal to` 1
artistList[0] `should equal` Artist(id = 522, name = "The Prodigy")
artistList[0] `should equal` Artist(id = "522", name = "The Prodigy")
albumList.size `should equal to` 1
albumList[0] `should equal` MusicDirectoryChild(id = 8867, parent = 522, isDir = true,
albumList[0] `should equal` MusicDirectoryChild(id = "8867", parent = "522", isDir = true,
title = "Always Outnumbered, Never Outgunned",
album = "Always Outnumbered, Never Outgunned", artist = "The Prodigy",
year = 2004, genre = "Electronic", coverArt = "8867", playCount = 0,
created = parseDate("2016-10-23T20:57:27.000Z"))
songList.size `should equal to` 1
songList[0] `should equal` MusicDirectoryChild(id = 5831, parent = 5766, isDir = false,
songList[0] `should equal` MusicDirectoryChild(id = "5831", parent = "5766", isDir = false,
title = "You'll Be Under My Wheels", album = "Need for Speed Most Wanted",
artist = "The Prodigy", track = 17, year = 2005, genre = "Rap",
coverArt = "5766", size = 5607024, contentType = "audio/mpeg",
@ -47,7 +47,7 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels.mp3",
isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T20:09:02.000Z"),
albumId = 568, artistId = 505, type = "music")
albumId = "568", artistId = "505", type = "music")
}
}
@ -113,7 +113,7 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
@Test
fun `Should pass music folder id in request param`() {
val musicFolderId = 565L
val musicFolderId = "565"
mockWebServerRule.assertRequestParam(responseResourceName = "search2_ok.json",
expectedParam = "musicFolderId=$musicFolderId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param`() {
val id = 110L
val id = "110"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
@ -37,7 +37,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass artist id param`() {
val artistId = 123L
val artistId = "123"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "artistId=$artistId") {
@ -47,7 +47,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass album id param`() {
val albumId = 1001L
val albumId = "1001"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "albumId=$albumId") {

View File

@ -27,7 +27,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass id param`() {
val id = 545L
val id = "545"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "id=$id") {
@ -37,7 +37,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass artistId param`() {
val artistId = 644L
val artistId = "644"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "artistId=$artistId") {
@ -47,7 +47,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
@Test
fun `Should pass albumId param`() {
val albumId = 3344L
val albumId = "3344"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "albumId=$albumId") {

View File

@ -9,7 +9,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.updatePlaylist(10).execute()
client.api.updatePlaylist("10").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.updatePlaylist(15).execute()
val response = client.api.updatePlaylist("15").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass playlist id param in request`() {
val id = 5453L
val id = "5453"
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "playlistId=$id") {
@ -38,7 +38,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "name=$name") {
client.api.updatePlaylist(22, name = name).execute()
client.api.updatePlaylist("22", name = name).execute()
}
}
@ -48,7 +48,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "comment=$comment") {
client.api.updatePlaylist(42, comment = comment).execute()
client.api.updatePlaylist("42", comment = comment).execute()
}
}
@ -58,17 +58,17 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "public=$public") {
client.api.updatePlaylist(53, public = public).execute()
client.api.updatePlaylist("53", public = public).execute()
}
}
@Test
fun `Should pass song ids to update in request`() {
val songIds = listOf(45L, 81L)
val songIds = listOf("45", "81")
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIdToAdd=${songIds[0]}&songIdToAdd=${songIds[1]}") {
client.api.updatePlaylist(25, songIdsToAdd = songIds).execute()
client.api.updatePlaylist("25", songIdsToAdd = songIds).execute()
}
}
@ -79,7 +79,7 @@ class SubsonicApiUpdatePlaylistTest : SubsonicAPIClientTest() {
mockWebServerRule.assertRequestParam(responseResourceName = "ping_ok.json",
expectedParam = "songIndexToRemove=${songIndexesToRemove[0]}&" +
"songIndexToRemove=${songIndexesToRemove[1]}") {
client.api.updatePlaylist(49, songIndexesToRemove = songIndexesToRemove).execute()
client.api.updatePlaylist("49", songIndexesToRemove = songIndexesToRemove).execute()
}
}
}

View File

@ -9,7 +9,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
@Test
fun `Should handle error response`() {
checkErrorCallParsed(mockWebServerRule) {
client.api.updateShare(11).execute()
client.api.updateShare("11").execute()
}
}
@ -17,14 +17,14 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
fun `Should handle ok response`() {
mockWebServerRule.enqueueResponse("ping_ok.json")
val response = client.api.updateShare(12).execute()
val response = client.api.updateShare("12").execute()
assertResponseSuccessful(response)
}
@Test
fun `Should pass id in request params`() {
val id = 4432L
val id = "4432"
mockWebServerRule.assertRequestParam(expectedParam = "id=$id") {
client.api.updateShare(id = id).execute()
@ -36,7 +36,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
val description = "some-description"
mockWebServerRule.assertRequestParam(expectedParam = "description=$description") {
client.api.updateShare(123, description = description).execute()
client.api.updateShare("123", description = description).execute()
}
}
@ -45,7 +45,7 @@ class SubsonicApiUpdateShareTest : SubsonicAPIClientTest() {
val expires = 223123123L
mockWebServerRule.assertRequestParam(expectedParam = "expires=$expires") {
client.api.updateShare(12, expires = expires).execute()
client.api.updateShare("12", expires = expires).execute()
}
}
}

View File

@ -45,27 +45,27 @@ import retrofit2.Call
internal class ApiVersionCheckWrapper(
val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions) : SubsonicAPIDefinition by api {
override fun getArtists(musicFolderId: Long?): Call<GetArtistsResponse> {
override fun getArtists(musicFolderId: String?): Call<GetArtistsResponse> {
checkVersion(V1_8_0)
return api.getArtists(musicFolderId)
}
override fun star(id: Long?, albumId: Long?, artistId: Long?): Call<SubsonicResponse> {
override fun star(id: String?, albumId: String?, artistId: String?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.star(id, albumId, artistId)
}
override fun unstar(id: Long?, albumId: Long?, artistId: Long?): Call<SubsonicResponse> {
override fun unstar(id: String?, albumId: String?, artistId: String?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.unstar(id, albumId, artistId)
}
override fun getArtist(id: Long): Call<GetArtistResponse> {
override fun getArtist(id: String): Call<GetArtistResponse> {
checkVersion(V1_8_0)
return api.getArtist(id)
}
override fun getAlbum(id: Long): Call<GetAlbumResponse> {
override fun getAlbum(id: String): Call<GetAlbumResponse> {
checkVersion(V1_8_0)
return api.getAlbum(id)
}
@ -76,7 +76,7 @@ internal class ApiVersionCheckWrapper(
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: Long?): Call<SearchTwoResponse> {
musicFolderId: String?): Call<SearchTwoResponse> {
checkVersion(V1_4_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search2(query, artistCount, artistOffset, albumCount, albumOffset, songCount,
@ -89,7 +89,7 @@ internal class ApiVersionCheckWrapper(
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: Long?): Call<SearchThreeResponse> {
musicFolderId: String?): Call<SearchThreeResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search3(query, artistCount, artistOffset, albumCount, albumOffset,
@ -101,29 +101,29 @@ internal class ApiVersionCheckWrapper(
return api.getPlaylists(username)
}
override fun createPlaylist(id: Long?,
override fun createPlaylist(id: String?,
name: String?,
songIds: List<Long>?): Call<SubsonicResponse> {
songIds: List<String>?): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.createPlaylist(id, name, songIds)
}
override fun deletePlaylist(id: Long): Call<SubsonicResponse> {
override fun deletePlaylist(id: String): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.deletePlaylist(id)
}
override fun updatePlaylist(id: Long,
override fun updatePlaylist(id: String,
name: String?,
comment: String?,
public: Boolean?,
songIdsToAdd: List<Long>?,
songIdsToAdd: List<String>?,
songIndexesToRemove: List<Int>?): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.updatePlaylist(id, name, comment, public, songIdsToAdd, songIndexesToRemove)
}
override fun getPodcasts(includeEpisodes: Boolean?, id: Long?): Call<GetPodcastsResponse> {
override fun getPodcasts(includeEpisodes: Boolean?, id: String?): Call<GetPodcastsResponse> {
checkVersion(V1_6_0)
checkParamVersion(includeEpisodes, V1_9_0)
checkParamVersion(id, V1_9_0)
@ -147,7 +147,7 @@ internal class ApiVersionCheckWrapper(
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: Long?): Call<GetAlbumListResponse> {
musicFolderId: String?): Call<GetAlbumListResponse> {
checkVersion(V1_2_0)
checkParamVersion(musicFolderId, V1_11_0)
return api.getAlbumList(type, size, offset, fromYear, toYear, genre, musicFolderId)
@ -159,7 +159,7 @@ internal class ApiVersionCheckWrapper(
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: Long?): Call<GetAlbumList2Response> {
musicFolderId: String?): Call<GetAlbumList2Response> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getAlbumList2(type, size, offset, fromYear, toYear, genre, musicFolderId)
@ -169,18 +169,18 @@ internal class ApiVersionCheckWrapper(
genre: String?,
fromYear: Int?,
toYear: Int?,
musicFolderId: Long?): Call<GetRandomSongsResponse> {
musicFolderId: String?): Call<GetRandomSongsResponse> {
checkVersion(V1_2_0)
return api.getRandomSongs(size, genre, fromYear, toYear, musicFolderId)
}
override fun getStarred(musicFolderId: Long?): Call<GetStarredResponse> {
override fun getStarred(musicFolderId: String?): Call<GetStarredResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getStarred(musicFolderId)
}
override fun getStarred2(musicFolderId: Long?): Call<GetStarredTwoResponse> {
override fun getStarred2(musicFolderId: String?): Call<GetStarredTwoResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getStarred2(musicFolderId)
@ -225,12 +225,12 @@ internal class ApiVersionCheckWrapper(
return api.createShare(idsToShare, description, expires)
}
override fun deleteShare(id: Long): Call<SubsonicResponse> {
override fun deleteShare(id: String): Call<SubsonicResponse> {
checkVersion(V1_6_0)
return api.deleteShare(id)
}
override fun updateShare(id: Long,
override fun updateShare(id: String,
description: String?,
expires: Long?): Call<SubsonicResponse> {
checkVersion(V1_6_0)
@ -245,7 +245,7 @@ internal class ApiVersionCheckWrapper(
override fun getSongsByGenre(genre: String,
count: Int,
offset: Int,
musicFolderId: Long?): Call<GetSongsByGenreResponse> {
musicFolderId: String?): Call<GetSongsByGenreResponse> {
checkVersion(V1_9_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getSongsByGenre(genre, count, offset, musicFolderId)
@ -271,12 +271,12 @@ internal class ApiVersionCheckWrapper(
return api.getBookmarks()
}
override fun createBookmark(id: Int, position: Long, comment: String?): Call<SubsonicResponse> {
override fun createBookmark(id: String, position: Long, comment: String?): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.createBookmark(id, position, comment)
}
override fun deleteBookmark(id: Int): Call<SubsonicResponse> {
override fun deleteBookmark(id: String): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.deleteBookmark(id)
}

View File

@ -54,30 +54,30 @@ interface SubsonicAPIDefinition {
fun getMusicFolders(): Call<MusicFoldersResponse>
@GET("getIndexes.view")
fun getIndexes(@Query("musicFolderId") musicFolderId: Long?,
fun getIndexes(@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?): Call<GetIndexesResponse>
@GET("getMusicDirectory.view")
fun getMusicDirectory(@Query("id") id: Long): Call<GetMusicDirectoryResponse>
fun getMusicDirectory(@Query("id") id: String): Call<GetMusicDirectoryResponse>
@GET("getArtists.view")
fun getArtists(@Query("musicFolderId") musicFolderId: Long?): Call<GetArtistsResponse>
fun getArtists(@Query("musicFolderId") musicFolderId: String?): Call<GetArtistsResponse>
@GET("star.view")
fun star(@Query("id") id: Long? = null,
@Query("albumId") albumId: Long? = null,
@Query("artistId") artistId: Long? = null): Call<SubsonicResponse>
fun star(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@GET("unstar.view")
fun unstar(@Query("id") id: Long? = null,
@Query("albumId") albumId: Long? = null,
@Query("artistId") artistId: Long? = null): Call<SubsonicResponse>
fun unstar(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
@GET("getArtist.view")
fun getArtist(@Query("id") id: Long): Call<GetArtistResponse>
fun getArtist(@Query("id") id: String): Call<GetArtistResponse>
@GET("getAlbum.view")
fun getAlbum(@Query("id") id: Long): Call<GetAlbumResponse>
fun getAlbum(@Query("id") id: String): Call<GetAlbumResponse>
@GET("search.view")
fun search(@Query("artist") artist: String? = null,
@ -95,7 +95,7 @@ interface SubsonicAPIDefinition {
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<SearchTwoResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchTwoResponse>
@GET("search3.view")
fun search3(@Query("query") query: String,
@ -104,34 +104,34 @@ interface SubsonicAPIDefinition {
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<SearchThreeResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchThreeResponse>
@GET("getPlaylist.view")
fun getPlaylist(@Query("id") id: Long): Call<GetPlaylistResponse>
fun getPlaylist(@Query("id") id: String): Call<GetPlaylistResponse>
@GET("getPlaylists.view")
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
@GET("createPlaylist.view")
fun createPlaylist(@Query("playlistId") id: Long? = null,
fun createPlaylist(@Query("playlistId") id: String? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<Long>? = null): Call<SubsonicResponse>
@Query("songId") songIds: List<String>? = null): Call<SubsonicResponse>
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: Long): Call<SubsonicResponse>
fun deletePlaylist(@Query("id") id: String): Call<SubsonicResponse>
@GET("updatePlaylist.view")
fun updatePlaylist(
@Query("playlistId") id: Long,
@Query("playlistId") id: String,
@Query("name") name: String? = null,
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<Long>? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null): Call<SubsonicResponse>
@GET("getPodcasts.view")
fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: Long? = null): Call<GetPodcastsResponse>
@Query("id") id: String? = null): Call<GetPodcastsResponse>
@GET("getLyrics.view")
fun getLyrics(@Query("artist") artist: String? = null,
@ -149,7 +149,7 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetAlbumListResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse>
@GET("getAlbumList2.view")
fun getAlbumList2(@Query("type") type: AlbumListType,
@ -158,20 +158,20 @@ interface SubsonicAPIDefinition {
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetAlbumList2Response>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response>
@GET("getRandomSongs.view")
fun getRandomSongs(@Query("size") size: Int? = null,
@Query("genre") genre: String? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetRandomSongsResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse>
@GET("getStarred.view")
fun getStarred(@Query("musicFolderId") musicFolderId: Long? = null): Call<GetStarredResponse>
fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse>
@GET("getStarred2.view")
fun getStarred2(@Query("musicFolderId") musicFolderId: Long? = null): Call<GetStarredTwoResponse>
fun getStarred2(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse>
@Streaming
@GET("getCoverArt.view")
@ -205,10 +205,10 @@ interface SubsonicAPIDefinition {
@Query("expires") expires: Long? = null): Call<SharesResponse>
@GET("deleteShare.view")
fun deleteShare(@Query("id") id: Long): Call<SubsonicResponse>
fun deleteShare(@Query("id") id: String): Call<SubsonicResponse>
@GET("updateShare.view")
fun updateShare(@Query("id") id: Long,
fun updateShare(@Query("id") id: String,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SubsonicResponse>
@ -220,7 +220,7 @@ interface SubsonicAPIDefinition {
@Query("genre") genre: String,
@Query("count") count: Int = 10,
@Query("offset") offset: Int = 0,
@Query("musicFolderId") musicFolderId: Long? = null): Call<GetSongsByGenreResponse>
@Query("musicFolderId") musicFolderId: String? = null): Call<GetSongsByGenreResponse>
@GET("getUser.view")
fun getUser(@Query("username") username: String): Call<GetUserResponse>
@ -236,12 +236,12 @@ interface SubsonicAPIDefinition {
@GET("createBookmark.view")
fun createBookmark(
@Query("id") id: Int,
@Query("id") id: String,
@Query("position") position: Long,
@Query("comment") comment: String? = null): Call<SubsonicResponse>
@GET("deleteBookmark.view")
fun deleteBookmark(@Query("id") id: Int): Call<SubsonicResponse>
fun deleteBookmark(@Query("id") id: String): Call<SubsonicResponse>
@GET("getVideos.view")
fun getVideos(): Call<VideosResponse>

View File

@ -4,11 +4,11 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Album(
val id: Long = -1L,
val id: String = "",
val name: String = "",
val coverArt: String = "",
val artist: String = "",
val artistId: Long = -1L,
val artistId: String = "",
val songCount: Int = 0,
val duration: Int = 0,
val created: Calendar? = null,

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Artist(val id: Long = -1,
data class Artist(val id: String = "",
val name: String = "",
val coverArt: String = "",
val albumCount: Int = 0,

View File

@ -3,8 +3,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class MusicDirectory(val id: Long = -1L,
val parent: Long = -1L,
data class MusicDirectory(val id: String = "",
val parent: String = "",
val name: String = "",
val userRating: Int = 0,
val averageRating: Float = 0.0f,

View File

@ -2,8 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class MusicDirectoryChild(val id: Long = -1L,
val parent: Long = -1L,
data class MusicDirectoryChild(val id: String = "",
val parent: String = "",
val isDir: Boolean = false,
val title: String = "",
val album: String = "",
@ -24,12 +24,12 @@ data class MusicDirectoryChild(val id: Long = -1L,
val playCount: Int = 0,
val discNumber: Int = -1,
val created: Calendar? = null,
val albumId: Long = -1,
val artistId: Long = -1,
val albumId: String = "",
val artistId: String = "",
val type: String = "",
val starred: Calendar? = null,
val streamId: Long = -1,
val channelId: Long = -1,
val streamId: String = "",
val channelId: String = "",
val description: String = "",
val status: String = "",
val publishDate: Calendar? = null,

View File

@ -1,3 +1,3 @@
package org.moire.ultrasonic.api.subsonic.models
data class MusicFolder(val id: Long = -1, val name: String = "")
data class MusicFolder(val id: String = "", val name: String = "")

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Playlist(
val id: Long = -1,
val id: String = "",
val name: String = "",
val owner: String = "",
val comment: String = "",

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class PodcastChannel(
val id: Long = -1,
val id: String = "",
val url: String = "",
val title: String = "",
val description: String = "",

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Share(
val id: Long = -1L,
val id: String = "",
val url: String = "",
val username: String = "",
val created: Calendar? = null,

View File

@ -1,33 +1,18 @@
package org.moire.ultrasonic.api.subsonic.response
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonToken
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.annotation.JsonProperty
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicFolder
class MusicFoldersResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonDeserialize(using = MusicFoldersDeserializer::class)
val musicFolders: List<MusicFolder> = emptyList()) :
error: SubsonicError?) :
SubsonicResponse(status, version, error) {
companion object {
class MusicFoldersDeserializer() : JsonDeserializer<List<MusicFolder>>() {
override fun deserialize(p: JsonParser, ctxt: DeserializationContext?): List<MusicFolder> {
p.nextToken()
if (p.currentName == "musicFolder" && p.nextToken() == JsonToken.START_ARRAY) {
val mfJavaType = ctxt!!.typeFactory
.constructCollectionType(List::class.java, MusicFolder::class.java)
return ctxt.readValue(p, mfJavaType)
}
@JsonProperty("musicFolders") private val wrapper = MusicFoldersWrapper()
throw JsonMappingException(p, "Failed to parse music folders list")
}
}
}
val musicFolders get() = wrapper.musicFolders
}
internal class MusicFoldersWrapper(
@JsonProperty("musicFolder") val musicFolders: List<MusicFolder> = emptyList())

View File

@ -37,10 +37,10 @@ class ApiVersionCheckWrapperTest {
wrapper.getAlbumList(BY_GENRE)
val throwCall = { wrapper.getAlbumList(BY_GENRE, musicFolderId = 12L) }
val throwCall = { wrapper.getAlbumList(BY_GENRE, musicFolderId = "12") }
throwCall `should throw` ApiNotSupportedException::class
verify(apiMock).getAlbumList(BY_GENRE)
verify(apiMock, never()).getAlbumList(BY_GENRE, musicFolderId = 12L)
verify(apiMock, never()).getAlbumList(BY_GENRE, musicFolderId = "12")
}
}

View File

@ -188,7 +188,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetIndexesResponse> response = subsonicAPIClient.getApi()
.getIndexes(musicFolderId == null ? null : Long.valueOf(musicFolderId), null).execute();
.getIndexes(musicFolderId, null).execute();
checkResponseSuccessful(response);
Indexes indexes = APIIndexesConverter.toDomainEntity(response.body().getIndexes());
@ -251,13 +251,9 @@ public class RESTMusicService implements MusicService {
String artistId,
Context context,
ProgressListener progressListener) throws Exception {
Long apiId = id == null ? null : Long.valueOf(id);
Long apiAlbumId = albumId == null ? null : Long.valueOf(albumId);
Long apiArtistId = artistId == null ? null : Long.valueOf(artistId);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.star(apiId, apiAlbumId, apiArtistId).execute();
.star(id, albumId, artistId).execute();
checkResponseSuccessful(response);
}
@ -267,13 +263,9 @@ public class RESTMusicService implements MusicService {
String artistId,
Context context,
ProgressListener progressListener) throws Exception {
Long apiId = id == null ? null : Long.valueOf(id);
Long apiAlbumId = albumId == null ? null : Long.valueOf(albumId);
Long apiArtistId = artistId == null ? null : Long.valueOf(artistId);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.unstar(apiId, apiAlbumId, apiArtistId).execute();
.unstar(id, albumId, artistId).execute();
checkResponseSuccessful(response);
}
@ -289,7 +281,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetMusicDirectoryResponse> response = subsonicAPIClient.getApi()
.getMusicDirectory(Long.valueOf(id)).execute();
.getMusicDirectory(id).execute();
checkResponseSuccessful(response);
return APIMusicDirectoryConverter.toDomainEntity(response.body().getMusicDirectory());
@ -306,8 +298,7 @@ public class RESTMusicService implements MusicService {
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetArtistResponse> response = subsonicAPIClient.getApi()
.getArtist(Long.valueOf(id)).execute();
Response<GetArtistResponse> response = subsonicAPIClient.getApi().getArtist(id).execute();
checkResponseSuccessful(response);
return APIArtistConverter.toMusicDirectoryDomainEntity(response.body().getArtist());
@ -324,8 +315,7 @@ public class RESTMusicService implements MusicService {
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetAlbumResponse> response = subsonicAPIClient.getApi()
.getAlbum(Long.valueOf(id)).execute();
Response<GetAlbumResponse> response = subsonicAPIClient.getApi().getAlbum(id).execute();
checkResponseSuccessful(response);
return APIAlbumConverter.toMusicDirectoryDomainEntity(response.body().getAlbum());
@ -406,7 +396,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetPlaylistResponse> response = subsonicAPIClient.getApi()
.getPlaylist(Long.valueOf(id)).execute();
.getPlaylist(id).execute();
checkResponseSuccessful(response);
MusicDirectory playlist = APIPlaylistConverter
@ -459,17 +449,16 @@ public class RESTMusicService implements MusicService {
List<MusicDirectory.Entry> entries,
Context context,
ProgressListener progressListener) throws Exception {
Long pId = id == null ? null : Long.valueOf(id);
List<Long> pSongIds = new ArrayList<>(entries.size());
List<String> pSongIds = new ArrayList<>(entries.size());
for (MusicDirectory.Entry entry : entries) {
if (entry.getId() != null) {
pSongIds.add(Long.valueOf(entry.getId()));
pSongIds.add(entry.getId());
}
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.createPlaylist(pId, name, pSongIds).execute();
.createPlaylist(id, name, pSongIds).execute();
checkResponseSuccessful(response);
}
@ -477,11 +466,9 @@ public class RESTMusicService implements MusicService {
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();
.deletePlaylist(id).execute();
checkResponseSuccessful(response);
}
@ -494,7 +481,7 @@ public class RESTMusicService implements MusicService {
ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.updatePlaylist(Long.valueOf(id), name, comment, pub, null, null).execute();
.updatePlaylist(id, name, comment, pub, null, null).execute();
checkResponseSuccessful(response);
}
@ -521,7 +508,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetPodcastsResponse> response = subsonicAPIClient.getApi()
.getPodcasts(true, Long.valueOf(podcastChannelId)).execute();
.getPodcasts(true, podcastChannelId).execute();
checkResponseSuccessful(response);
List<MusicDirectoryChild> podcastEntries = response.body().getPodcastChannels().get(0)
@ -668,7 +655,7 @@ public class RESTMusicService implements MusicService {
Log.d(TAG, "Loading cover art for: " + entry);
final String id = entry.getCoverArt();
if (id == null) {
if (id == null || id.isEmpty()) {
return null; // Can't load
}
@ -947,10 +934,9 @@ public class RESTMusicService implements MusicService {
if (id == null) {
throw new IllegalArgumentException("Item id should not be null");
}
Integer itemId = Integer.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.createBookmark(itemId, position, null).execute();
.createBookmark(id, position, null).execute();
checkResponseSuccessful(response);
}
@ -965,7 +951,7 @@ public class RESTMusicService implements MusicService {
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.deleteBookmark(itemId).execute();
.deleteBookmark(id).execute();
checkResponseSuccessful(response);
}
@ -1008,8 +994,7 @@ public class RESTMusicService implements MusicService {
Long shareId = Long.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.deleteShare(shareId).execute();
Response<SubsonicResponse> response = subsonicAPIClient.getApi().deleteShare(id).execute();
checkResponseSuccessful(response);
}
@ -1027,11 +1012,9 @@ public class RESTMusicService implements MusicService {
expires = null;
}
Long shareId = Long.valueOf(id);
updateProgressListener(progressListener, R.string.parser_reading);
Response<SubsonicResponse> response = subsonicAPIClient.getApi()
.updateShare(shareId, description, expires).execute();
.updateShare(id, description, expires).execute();
checkResponseSuccessful(response);
}

View File

@ -7,12 +7,12 @@ import org.moire.ultrasonic.api.subsonic.models.Album
import org.moire.ultrasonic.domain.MusicDirectory
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
id = this@toDomainEntity.id.toString()
id = this@toDomainEntity.id
setIsDirectory(true)
title = this@toDomainEntity.name
coverArt = this@toDomainEntity.coverArt
artist = this@toDomainEntity.artist
artistId = this@toDomainEntity.artistId.toString()
artistId = this@toDomainEntity.artistId
songCount = this@toDomainEntity.songCount.toLong()
duration = this@toDomainEntity.duration
created = this@toDomainEntity.created?.time

View File

@ -8,7 +8,7 @@ import org.moire.ultrasonic.domain.MusicDirectory
import org.moire.ultrasonic.api.subsonic.models.Artist as APIArtist
fun APIArtist.toDomainEntity(): Artist = Artist().apply {
id = this@toDomainEntity.id.toString()
id = this@toDomainEntity.id
name = this@toDomainEntity.name
}

View File

@ -15,14 +15,14 @@ internal val dateFormat: DateFormat by lazy {
}
fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
id = this@toDomainEntity.id.toString()
parent = this@toDomainEntity.parent.toString()
id = this@toDomainEntity.id
parent = this@toDomainEntity.parent
setIsDirectory(this@toDomainEntity.isDir)
title = this@toDomainEntity.title
album = this@toDomainEntity.album
albumId = this@toDomainEntity.albumId.toString()
albumId = this@toDomainEntity.albumId
artist = this@toDomainEntity.artist
artistId = this@toDomainEntity.artistId.toString()
artistId = this@toDomainEntity.artistId
track = this@toDomainEntity.track
year = this@toDomainEntity.year
genre = this@toDomainEntity.genre
@ -40,8 +40,8 @@ fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.
starred = this@toDomainEntity.starred != null
discNumber = this@toDomainEntity.discNumber
type = this@toDomainEntity.type
if (this@toDomainEntity.streamId >= 0) {
id = this@toDomainEntity.streamId.toString()
if (this@toDomainEntity.streamId.isNotBlank()) {
id = this@toDomainEntity.streamId
}
if (this@toDomainEntity.publishDate != null) {
artist = dateFormat.format(this@toDomainEntity.publishDate!!.time)

View File

@ -6,7 +6,7 @@ package org.moire.ultrasonic.data
import org.moire.ultrasonic.domain.MusicFolder
import org.moire.ultrasonic.api.subsonic.models.MusicFolder as APIMusicFolder
fun APIMusicFolder.toDomainEntity(): MusicFolder = MusicFolder(this.id.toString(), this.name)
fun APIMusicFolder.toDomainEntity(): MusicFolder = MusicFolder(this.id, this.name)
fun List<APIMusicFolder>.toDomainEntityList(): List<MusicFolder>
= this.map { it.toDomainEntity() }

View File

@ -16,7 +16,7 @@ fun APIPlaylist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory(
addAll(this@toMusicDirectoryDomainEntity.entriesList.map { it.toDomainEntity() })
}
fun APIPlaylist.toDomainEntity(): Playlist = Playlist(this.id.toString(), this.name, this.owner,
fun APIPlaylist.toDomainEntity(): Playlist = Playlist(this.id, this.name, this.owner,
this.comment, this.songCount.toString(),
this.created?.let { playlistDateFormat.format(it.time) },
public.toString())

View File

@ -7,7 +7,7 @@ import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
import org.moire.ultrasonic.domain.PodcastsChannel
fun PodcastChannel.toDomainEntity(): PodcastsChannel = PodcastsChannel(
this.id.toString(), this.title, this.url, this.description, this.status)
this.id, this.title, this.url, this.description, this.status)
fun List<PodcastChannel>.toDomainEntitiesList(): List<PodcastsChannel> = this
.map { it.toDomainEntity() }

View File

@ -17,7 +17,7 @@ fun APIShare.toDomainEntity(): Share = Share().apply {
created = this@toDomainEntity.created?.let { shareTimeFormat.format(it.time) }
description = this@toDomainEntity.description
expires = this@toDomainEntity.expires?.let { shareTimeFormat.format(it.time) }
id = this@toDomainEntity.id.toString()
id = this@toDomainEntity.id
lastVisited = this@toDomainEntity.lastVisited?.let { shareTimeFormat.format(it.time) }
url = this@toDomainEntity.url
username = this@toDomainEntity.username

View File

@ -15,19 +15,19 @@ import java.util.Calendar
class APIAlbumConverterTest {
@Test
fun `Should convert Album to domain entity`() {
val entity = Album(id = 387L, name = "some-name", coverArt = "asdas", artist = "some-artist",
artistId = 390L, songCount = 12, duration = 841, created = Calendar.getInstance(),
val entity = Album(id = "387", name = "some-name", coverArt = "asdas", artist = "some-artist",
artistId = "390", songCount = 12, duration = 841, created = Calendar.getInstance(),
year = 2017, genre = "some-genre")
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id.toString()
id `should equal to` entity.id
title `should equal to` entity.name
isDirectory `should equal to` true
coverArt `should equal to` entity.coverArt
artist `should equal to` entity.artist
artistId `should equal to` entity.artistId.toString()
artistId `should equal to` entity.artistId
songCount `should equal to` entity.songCount.toLong()
duration `should equal to` entity.duration
created `should equal` entity.created?.time
@ -38,7 +38,7 @@ class APIAlbumConverterTest {
@Test
fun `Should convert to MusicDirectory domain entity`() {
val entity = Album(id = 101L, name = "some-album", artist = "some-artist", artistId = 54L,
val entity = Album(id = "101", name = "some-album", artist = "some-artist", artistId = "54",
coverArt = "some-id", songCount = 10, duration = 456,
created = Calendar.getInstance(), year = 2022, genre = "Hard Rock",
songList = listOf(MusicDirectoryChild()))
@ -54,7 +54,7 @@ class APIAlbumConverterTest {
@Test
fun `Should convert list of Album entities to domain list entities`() {
val entityList = listOf(Album(id = 455), Album(id = 1), Album(id = 1000))
val entityList = listOf(Album(id = "455"), Album(id = "1"), Album(id = "1000"))
val convertedList = entityList.toDomainEntityList()

View File

@ -10,26 +10,26 @@ import org.moire.ultrasonic.api.subsonic.models.Artist
import java.util.Calendar
/**
* Unit test for extension functions in [APIArtistConverter.kt] file.
* Unit test for extension functions in APIArtistConverter.kt file.
*/
class APIArtistConverterTest {
@Test
fun `Should convert artist entity`() {
val entity = Artist(id = 10, name = "artist-name", starred = Calendar.getInstance())
val entity = Artist(id = "10", name = "artist-name", starred = Calendar.getInstance())
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id.toString()
id `should equal to` entity.id
name `should equal to` entity.name
}
}
@Test
fun `Should convert Artist entity to domain MusicDirectory entity`() {
val entity = Artist(id = 101L, name = "artist-name", coverArt = "some-art", albumCount = 10,
albumsList = listOf(Album(id = 562L, name = "some-name", coverArt = "zzz",
artist = "artist-name", artistId = 256L, songCount = 10, duration = 345,
val entity = Artist(id = "101", name = "artist-name", coverArt = "some-art", albumCount = 10,
albumsList = listOf(Album(id = "562", name = "some-name", coverArt = "zzz",
artist = "artist-name", artistId = "256", songCount = 10, duration = 345,
created = Calendar.getInstance(), year = 2011, genre = "Math Rock")))
val convertedEntity = entity.toMusicDirectoryDomainEntity()

View File

@ -16,7 +16,7 @@ class APIBookmarkConverterTest {
@Test
fun `Should convert to domain entity`() {
val entity = Bookmark(412313L, "Awesemo", "Nice", Calendar.getInstance(),
Calendar.getInstance(), MusicDirectoryChild(id = 12333))
Calendar.getInstance(), MusicDirectoryChild(id = "12333"))
val domainEntity = entity.toDomainEntity()

View File

@ -16,11 +16,11 @@ class APIIndexesConverterTest {
@Test
fun `Should convert Indexes entity`() {
val artistsA = listOf(
Artist(id =4, name = "AC/DC"),
Artist(id =45, name = "ABBA"))
Artist(id ="4", name = "AC/DC"),
Artist(id ="45", name = "ABBA"))
val artistsT = listOf(
Artist(id = 10, name = "Taproot"),
Artist(id = 12, name = "Teebee"))
Artist(id = "10", name = "Taproot"),
Artist(id = "12", name = "Teebee"))
val entity = Indexes(lastModified = 154, ignoredArticles = "Le Tre Ze", indexList = listOf(
Index(name = "A", artists = artistsA),
Index(name = "T", artists = artistsT)

View File

@ -10,14 +10,14 @@ import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
import java.util.Calendar
/**
* Unit test for extension functions in [APIMusicDirectoryConverter.kt] file.
* Unit test for extension functions in APIMusicDirectoryConverter.kt file.
*/
class APIMusicDirectoryConverterTest {
@Test
fun `Should convert MusicDirectory entity`() {
val entity = MusicDirectory(id = 1982L, parent = 345L, name = "some-name", userRating = 3,
val entity = MusicDirectory(id = "1982", parent = "345", name = "some-name", userRating = 3,
averageRating = 3.4f, starred = Calendar.getInstance(), playCount = 10,
childList = listOf(MusicDirectoryChild(1L), MusicDirectoryChild(2L)))
childList = listOf(MusicDirectoryChild("1"), MusicDirectoryChild("2")))
val convertedEntity = entity.toDomainEntity()
@ -30,8 +30,8 @@ class APIMusicDirectoryConverterTest {
@Test
fun `Should convert MusicDirectoryChild entity`() {
val entity = MusicDirectoryChild(id = 929L, parent = 11L, title = "some-title",
album = "some-album", albumId = 231L, artist = "some-artist", artistId = 1233L,
val entity = MusicDirectoryChild(id = "929", parent = "11", title = "some-title",
album = "some-album", albumId = "231", artist = "some-artist", artistId = "1233",
track = 12, year = 2002, genre = "some-genre", coverArt = "952", size = 9418123L,
contentType = "some-content-type", suffix = "some-suffix",
transcodedContentType = "some-transcoded-content-type",
@ -42,14 +42,14 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id.toString()
parent `should equal to` entity.parent.toString()
id `should equal to` entity.id
parent `should equal to` entity.parent
isDirectory `should equal to` entity.isDir
title `should equal` entity.title
album `should equal` entity.album
albumId `should equal to` entity.albumId.toString()
albumId `should equal to` entity.albumId
artist `should equal to` entity.artist
artistId `should equal to` entity.artistId.toString()
artistId `should equal to` entity.artistId
track `should equal to` entity.track
year `should equal to` entity.year!!
genre `should equal to` entity.genre
@ -72,20 +72,20 @@ class APIMusicDirectoryConverterTest {
@Test
fun `Should convert MusicDirectoryChild podcast entity`() {
val entity = MusicDirectoryChild(id = 584, streamId = 394,
val entity = MusicDirectoryChild(id = "584", streamId = "394",
artist = "some-artist", publishDate = Calendar.getInstance())
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.streamId.toString()
id `should equal to` entity.streamId
artist `should equal to` dateFormat.format(entity.publishDate?.time)
}
}
@Test
fun `Should convert list of MusicDirectoryChild to domain entity list`() {
val entitiesList = listOf(MusicDirectoryChild(id = 45), MusicDirectoryChild(id = 34))
val entitiesList = listOf(MusicDirectoryChild(id = "45"), MusicDirectoryChild(id = "34"))
val domainList = entitiesList.toDomainEntityList()

View File

@ -12,27 +12,27 @@ import org.moire.ultrasonic.api.subsonic.models.MusicFolder
class APIMusicFolderConverterTest {
@Test
fun `Should convert MusicFolder entity`() {
val entity = MusicFolder(id = 10, name = "some-name")
val entity = MusicFolder(id = "10", name = "some-name")
val convertedEntity = entity.toDomainEntity()
convertedEntity.name `should equal to` entity.name
convertedEntity.id `should equal to` entity.id.toString()
convertedEntity.id `should equal to` entity.id
}
@Test
fun `Should convert list of MusicFolder entities`() {
val entityList = listOf(
MusicFolder(id = 3, name = "some-name-3"),
MusicFolder(id = 4, name = "some-name-4"))
MusicFolder(id = "3", name = "some-name-3"),
MusicFolder(id = "4", name = "some-name-4"))
val convertedList = entityList.toDomainEntityList()
with(convertedList) {
size `should equal to` entityList.size
this[0].id `should equal to` entityList[0].id.toString()
this[0].id `should equal to` entityList[0].id
this[0].name `should equal to` entityList[0].name
this[1].id `should equal to` entityList[1].id.toString()
this[1].id `should equal to` entityList[1].id
this[1].name `should equal to` entityList[1].name
}
}

View File

@ -16,8 +16,8 @@ class APIPlaylistConverterTest {
@Test
fun `Should convert Playlist to MusicDirectory domain entity`() {
val entity = Playlist(name = "some-playlist-name", entriesList = listOf(
MusicDirectoryChild(id = 10L, parent = 1393),
MusicDirectoryChild(id = 11L, parent = 1393)
MusicDirectoryChild(id = "10", parent = "1393"),
MusicDirectoryChild(id = "11", parent = "1393")
))
val convertedEntity = entity.toMusicDirectoryDomainEntity()
@ -32,7 +32,7 @@ class APIPlaylistConverterTest {
@Test
fun `Should convert playlist to domain entity`() {
val entity = Playlist(id = 634, name = "some-name", owner = "some-owner",
val entity = Playlist(id = "634", name = "some-name", owner = "some-owner",
comment = "some-comment", public = false, songCount = 256, duration = 1150,
created = Calendar.getInstance(), changed = Calendar.getInstance(),
coverArt = "some-art")
@ -40,7 +40,7 @@ class APIPlaylistConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id.toString()
id `should equal to` entity.id
name `should equal to` entity.name
comment `should equal to` entity.comment
owner `should equal to` entity.owner
@ -52,7 +52,7 @@ class APIPlaylistConverterTest {
@Test
fun `Should convert list of playlists to list of domain entities`() {
val entitiesList = listOf(Playlist(id = 23, name = "some-name", songCount = 10))
val entitiesList = listOf(Playlist(id = "23", name = "some-name", songCount = 10))
val convertedList = entitiesList.toDomainEntitiesList()

View File

@ -8,19 +8,19 @@ import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
/**
* Unit test for extension functions in [APIPodcastConverter.kt] file.
* Unit test for extension functions in APIPodcastConverter.kt file.
*/
class APIPodcastConverterTest {
@Test
fun `Should convert podcast channel entity to domain entity`() {
val entity = PodcastChannel(id = 452L, url = "some-url", title = "some-title",
val entity = PodcastChannel(id = "452", url = "some-url", title = "some-title",
description = "some-description", coverArt = "cA", originalImageUrl = "image-url",
status = "podcast-status", errorMessage = "some-error-message")
val converterEntity = entity.toDomainEntity()
with(converterEntity) {
id = entity.id.toString()
id = entity.id
description = entity.description
status = entity.status
title = entity.title
@ -31,8 +31,8 @@ class APIPodcastConverterTest {
@Test
fun `Should convert list of podcasts channels to domain entites list`() {
val entitiesList = listOf(
PodcastChannel(id = 932L, title = "title1"),
PodcastChannel(id = 12L, title = "title2"))
PodcastChannel(id = "932", title = "title1"),
PodcastChannel(id = "12", title = "title2"))
val converted = entitiesList.toDomainEntitiesList()

View File

@ -14,13 +14,13 @@ import org.moire.ultrasonic.api.subsonic.models.SearchThreeResult
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
/**
* Unit test for extension function in [APISearchConverter.kt] file.
* Unit test for extension function in APISearchConverter.kt file.
*/
class APISearchConverterTest {
@Test
fun `Should convert SearchResult to domain entity`() {
val entity = SearchResult(offset = 10, totalHits = 3, matchList = listOf(
MusicDirectoryChild(id = 101L)
MusicDirectoryChild(id = "101")
))
val convertedEntity = entity.toDomainEntity()
@ -38,11 +38,11 @@ class APISearchConverterTest {
@Test
fun `Should convert SearchTwoResult to domain entity`() {
val entity = SearchTwoResult(listOf(
Artist(id = 82, name = "great-artist-name")
Artist(id = "82", name = "great-artist-name")
), listOf(
MusicDirectoryChild(id = 762, artist = "bzz")
MusicDirectoryChild(id = "762", artist = "bzz")
), listOf(
MusicDirectoryChild(id = 9118, parent = 112)
MusicDirectoryChild(id = "9118", parent = "112")
))
val convertedEntity = entity.toDomainEntity()
@ -60,9 +60,9 @@ class APISearchConverterTest {
@Test
fun `Should convert SearchThreeResult to domain entity`() {
val entity = SearchThreeResult(
artistList = listOf(Artist(id = 612, name = "artist1")),
albumList = listOf(Album(id = 221, name = "album1")),
songList = listOf(MusicDirectoryChild(id = 7123, title = "song1"))
artistList = listOf(Artist(id = "612", name = "artist1")),
albumList = listOf(Album(id = "221", name = "album1")),
songList = listOf(MusicDirectoryChild(id = "7123", title = "song1"))
)
val convertedEntity = entity.toDomainEntity()

View File

@ -20,7 +20,7 @@ class APIShareConverterTest {
val domainEntity = entity.toDomainEntity()
with(domainEntity) {
id `should equal to` entity.id.toString()
id `should equal to` entity.id
url `should equal to` entity.url
description `should equal to` entity.description
username `should equal to` entity.username
@ -33,7 +33,7 @@ class APIShareConverterTest {
}
private fun createFakeShare(): Share {
return Share(id = 45L, url = "some-long-url", username = "Bender",
return Share(id = "45", url = "some-long-url", username = "Bender",
created = Calendar.getInstance(), expires = Calendar.getInstance(), visitCount = 24,
description = "Kiss my shiny metal ass", lastVisited = Calendar.getInstance(),
items = listOf(MusicDirectoryChild()))
@ -43,7 +43,7 @@ class APIShareConverterTest {
fun `Should parse list of shares into domain entity list`() {
val entityList = listOf(
createFakeShare(),
createFakeShare().copy(id = 554L, lastVisited = null))
createFakeShare().copy(id = "554", lastVisited = null))
val domainEntityList = entityList.toDomainEntitiesList()