Update KtLint to 0.14.0 version.

Also fix style problems.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2017-12-21 10:44:19 +01:00
parent 11c1b92098
commit 07802e9206
26 changed files with 135 additions and 99 deletions

View File

@ -5,7 +5,7 @@ ext.versions = [
gradle : '4.4.1', gradle : '4.4.1',
androidTools : "3.0.1", androidTools : "3.0.1",
ktlint : "0.12.1", ktlint : "0.14.0",
ktlintGradle : "2.3.0", ktlintGradle : "2.3.0",
detekt : "1.0.0.RC6", detekt : "1.0.0.RC6",
jacoco : "0.7.9", jacoco : "0.7.9",

View File

@ -14,7 +14,7 @@ abstract class SubsonicAPIClientTest {
@Before @Before
fun setUp() { fun setUp() {
client = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(), USERNAME, PASSWORD, client = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(),
CLIENT_VERSION, CLIENT_ID) USERNAME, PASSWORD, CLIENT_VERSION, CLIENT_ID)
} }
} }

View File

@ -50,16 +50,18 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
year `should equal to` 2008 year `should equal to` 2008
genre `should equal to` "Hard Rock" genre `should equal to` "Hard Rock"
songList.size `should equal to` 15 songList.size `should equal to` 15
songList[0] `should equal` MusicDirectoryChild(id = "6491", parent = "6475", isDir = false, songList[0] `should equal` MusicDirectoryChild(id = "6491", parent = "6475",
title = "Rock 'n' Roll Train", album = "Black Ice", artist = "AC/DC", isDir = false, title = "Rock 'n' Roll Train", album = "Black Ice",
track = 1, year = 2008, genre = "Hard Rock", coverArt = "6475", size = 7205451, artist = "AC/DC", track = 1, year = 2008, genre = "Hard Rock",
contentType = "audio/mpeg", suffix = "mp3", duration = 261, bitRate = 219, coverArt = "6475", size = 7205451, contentType = "audio/mpeg", suffix = "mp3",
path = "AC_DC/Black Ice/01 Rock 'n' Roll Train.mp3", isVideo = false, duration = 261, bitRate = 219,
playCount = 0, discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"), 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 = "618", artistId = "362", type = "music") albumId = "618", artistId = "362", type = "music")
songList[5] `should equal` MusicDirectoryChild(id = "6492", parent = "6475", isDir = false, songList[5] `should equal` MusicDirectoryChild(id = "6492", parent = "6475",
title = "Smash 'n' Grab", album = "Black Ice", artist = "AC/DC", track = 6, isDir = false, title = "Smash 'n' Grab", album = "Black Ice", artist = "AC/DC",
year = 2008, genre = "Hard Rock", coverArt = "6475", size = 6697204, track = 6, year = 2008, genre = "Hard Rock", coverArt = "6475", size = 6697204,
contentType = "audio/mpeg", suffix = "mp3", duration = 246, bitRate = 216, contentType = "audio/mpeg", suffix = "mp3", duration = 246, bitRate = 216,
path = "AC_DC/Black Ice/06 Smash 'n' Grab.mp3", isVideo = false, playCount = 0, path = "AC_DC/Black Ice/06 Smash 'n' Grab.mp3", isVideo = false, playCount = 0,
discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"), discNumber = 1, created = parseDate("2016-10-23T15:31:20.000Z"),

View File

@ -37,11 +37,14 @@ class SubsonicApiGetArtistsTest : SubsonicAPIClientTest() {
indexList `should equal` listOf( indexList `should equal` listOf(
Index(name = "A", artists = listOf( Index(name = "A", artists = listOf(
Artist(id = "362", name = "AC/DC", coverArt = "ar-362", albumCount = 2), Artist(id = "362", name = "AC/DC", coverArt = "ar-362", albumCount = 2),
Artist(id = "254", name = "Acceptance", coverArt = "ar-254", albumCount = 1) Artist(id = "254", name = "Acceptance", coverArt = "ar-254",
albumCount = 1)
)), )),
Index(name = "T", artists = listOf( Index(name = "T", artists = listOf(
Artist(id = "516", name = "Tangerine Dream", coverArt = "ar-516", albumCount = 1), Artist(id = "516", name = "Tangerine Dream", coverArt = "ar-516",
Artist(id = "242", name = "Taproot", coverArt = "ar-242", albumCount = 2) albumCount = 1),
Artist(id = "242", name = "Taproot", coverArt = "ar-242",
albumCount = 2)
)) ))
) )
} }

View File

@ -50,19 +50,21 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
starred `should equal` null starred `should equal` null
playCount `should equal to` 1 playCount `should equal to` 1
childList.size `should be` 2 childList.size `should be` 2
childList[0] `should equal` MusicDirectoryChild(id = "4844", parent = "4836", isDir = false, childList[0] `should equal` MusicDirectoryChild(id = "4844", parent = "4836",
title = "Crash", album = "12 Stones", artist = "12 Stones", track = 1, year = 2002, isDir = false, title = "Crash", album = "12 Stones", artist = "12 Stones",
genre = "Alternative Rock", coverArt = "4836", size = 5348318L, track = 1, year = 2002, genre = "Alternative Rock", coverArt = "4836",
contentType = "audio/mpeg", suffix = "mp3", duration = 222, bitRate = 192, size = 5348318L, contentType = "audio/mpeg", suffix = "mp3", duration = 222,
path = "12 Stones/12 Stones/01 Crash.mp3", isVideo = false, playCount = 0, bitRate = 192, path = "12 Stones/12 Stones/01 Crash.mp3", isVideo = false,
discNumber = 1, created = parseDate("2016-10-23T15:19:10.000Z"), playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T15:19:10.000Z"),
albumId = "454", artistId = "288", type = "music") albumId = "454", artistId = "288", type = "music")
childList[1] `should equal` MusicDirectoryChild(id = "4845", parent = "4836", isDir = false, childList[1] `should equal` MusicDirectoryChild(id = "4845", parent = "4836",
title = "Broken", album = "12 Stones", artist = "12 Stones", track = 2, year = 2002, isDir = false, title = "Broken", album = "12 Stones", artist = "12 Stones",
genre = "Alternative Rock", coverArt = "4836", size = 4309043L, track = 2, year = 2002, genre = "Alternative Rock", coverArt = "4836",
contentType = "audio/mpeg", suffix = "mp3", duration = 179, bitRate = 192, size = 4309043L, contentType = "audio/mpeg", suffix = "mp3", duration = 179,
path = "12 Stones/12 Stones/02 Broken.mp3", isVideo = false, playCount = 0, bitRate = 192, path = "12 Stones/12 Stones/02 Broken.mp3", isVideo = false,
discNumber = 1, created = parseDate("2016-10-23T15:19:09.000Z"), playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T15:19:09.000Z"),
albumId = "454", artistId = "288", type = "music") albumId = "454", artistId = "288", type = "music")
} }
} }

View File

@ -33,13 +33,16 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
id `should equal to` "2" id `should equal to` "2"
url `should equal to` "http://feeds.codenewbie.org/cnpodcast.xml" url `should equal to` "http://feeds.codenewbie.org/cnpodcast.xml"
title `should equal to` "CodeNewbie" title `should equal to` "CodeNewbie"
description `should equal to` "Stories and interviews from people on their coding journey." description `should equal to` "Stories and interviews from people on their coding " +
"journey."
coverArt `should equal to` "pod-2" coverArt `should equal to` "pod-2"
originalImageUrl `should equal to` "http://codenewbie.blubrry.com/wp-content/uploads/powerpress/220808.jpg" originalImageUrl `should equal to` "http://codenewbie.blubrry.com/wp-content/uploads/" +
"powerpress/220808.jpg"
status `should equal to` "completed" status `should equal to` "completed"
errorMessage `should equal to` "" errorMessage `should equal to` ""
episodeList.size `should equal to` 10 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)", title = "S1:EP3 How to teach yourself computer science (Vaidehi Joshi)",
album = "CodeNewbie", artist = "podcasts", coverArt = "9959", album = "CodeNewbie", artist = "podcasts", coverArt = "9959",
size = 38274221, contentType = "audio/mpeg", suffix = "mp3", size = 38274221, contentType = "audio/mpeg", suffix = "mp3",
@ -56,7 +59,8 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
"CodeNewbie basecs 100 Days of Code Conway's Game of Life Hexes and " + "CodeNewbie basecs 100 Days of Code Conway's Game of Life Hexes and " +
"Other Magical Numbers (Vaidehi's blog post) Bits, Bytes, Building " + "Other Magical Numbers (Vaidehi's blog post) Bits, Bytes, Building " +
"With Binary (Vaidehi's blog post) Rust", "With Binary (Vaidehi's blog post) Rust",
status = "completed", publishDate = parseDate("2017-08-29T00:01:01.000Z")) status = "completed",
publishDate = parseDate("2017-08-29T00:01:01.000Z"))
} }
} }

View File

@ -39,8 +39,10 @@ class SubsonicApiGetSongsByGenreTest : SubsonicAPIClientTest() {
artist = "DJ Polyakov PPK Feat Kate Cameron", year = 2009, genre = "Trance", artist = "DJ Polyakov PPK Feat Kate Cameron", year = 2009, genre = "Trance",
size = 26805932, contentType = "audio/mpeg", suffix = "mp3", duration = 670, size = 26805932, contentType = "audio/mpeg", suffix = "mp3", duration = 670,
bitRate = 320, bitRate = 320,
path = "DJ Polyakov PPK Feat Kate Cameron/668/00 My Heart (Vadim Zhukov Remix).mp3", path = "DJ Polyakov PPK Feat Kate Cameron/668/00 My Heart (Vadim Zhukov " +
isVideo = false, playCount = 2, created = parseDate("2016-10-23T21:58:29.000Z"), "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")
} }
} }

View File

@ -27,11 +27,13 @@ class SubsonicApiGetVideosListTest : SubsonicAPIClientTest() {
assertResponseSuccessful(response) assertResponseSuccessful(response)
with(response.body().videosList) { with(response.body().videosList) {
size `should equal to` 1 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",
title = "MVI_0512", album = "Incoming", size = 21889646, isDir = false, title = "MVI_0512", album = "Incoming", size = 21889646,
contentType = "video/avi", suffix = "avi", transcodedContentType = "video/x-flv", contentType = "video/avi", suffix = "avi",
transcodedSuffix = "flv", path = "Incoming/MVI_0512.avi", isVideo = true, transcodedContentType = "video/x-flv", transcodedSuffix = "flv",
playCount = 0, created = parseDate("2017-11-19T12:34:33.000Z"), type = "video") path = "Incoming/MVI_0512.avi", isVideo = true,
playCount = 0, created = parseDate("2017-11-19T12:34:33.000Z"),
type = "video")
} }
} }
} }

View File

@ -56,8 +56,8 @@ class SubsonicApiJukeboxControlTest : SubsonicAPIClientTest() {
artist = "The Pretty Reckless", track = 2, year = 2014, genre = "Hard Rock", artist = "The Pretty Reckless", track = 2, year = 2014, genre = "Hard Rock",
coverArt = "4186", size = 11089627, contentType = "audio/mpeg", coverArt = "4186", size = 11089627, contentType = "audio/mpeg",
suffix = "mp3", duration = 277, bitRate = 320, suffix = "mp3", duration = 277, bitRate = 320,
path = "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3", isVideo = false, path = "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3",
playCount = 0, discNumber = 1, isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T21:30:41.000Z"), albumId = "388", created = parseDate("2016-10-23T21:30:41.000Z"), albumId = "388",
artistId = "238", type = "music") artistId = "238", type = "music")
} }

View File

@ -10,8 +10,8 @@ import org.junit.Test
class SubsonicApiPasswordTest : SubsonicAPIClientTest() { class SubsonicApiPasswordTest : SubsonicAPIClientTest() {
@Test @Test
fun `Should pass PasswordMD5Interceptor in query params for api version 1 13 0`() { fun `Should pass PasswordMD5Interceptor in query params for api version 1 13 0`() {
val clientV12 = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(), USERNAME, val clientV12 = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(),
PASSWORD, SubsonicAPIVersions.V1_14_0, CLIENT_ID) USERNAME, PASSWORD, SubsonicAPIVersions.V1_14_0, CLIENT_ID)
mockWebServerRule.enqueueResponse("ping_ok.json") mockWebServerRule.enqueueResponse("ping_ok.json")
clientV12.api.ping().execute() clientV12.api.ping().execute()
@ -25,8 +25,8 @@ class SubsonicApiPasswordTest : SubsonicAPIClientTest() {
@Test @Test
fun `Should pass PasswordHexInterceptor in query params for api version 1 12 0`() { fun `Should pass PasswordHexInterceptor in query params for api version 1 12 0`() {
val clientV11 = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(), USERNAME, val clientV11 = SubsonicAPIClient(mockWebServerRule.mockWebServer.url("/").toString(),
PASSWORD, SubsonicAPIVersions.V1_12_0, CLIENT_ID) USERNAME, PASSWORD, SubsonicAPIVersions.V1_12_0, CLIENT_ID)
mockWebServerRule.enqueueResponse("ping_ok.json") mockWebServerRule.enqueueResponse("ping_ok.json")
clientV11.api.ping().execute() clientV11.api.ping().execute()

View File

@ -39,7 +39,8 @@ class SubsonicApiSearchTest : SubsonicAPIClientTest() {
track = 17, year = 2005, genre = "Rap", coverArt = "5766", track = 17, year = 2005, genre = "Rap", coverArt = "5766",
size = 5607024, contentType = "audio/mpeg", suffix = "mp3", duration = 233, size = 5607024, contentType = "audio/mpeg", suffix = "mp3", duration = 233,
bitRate = 192, bitRate = 192,
path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels.mp3", path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels" +
".mp3",
isVideo = false, playCount = 0, discNumber = 1, isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T20:09:02.000Z"), albumId = "568", created = parseDate("2016-10-23T20:09:02.000Z"), albumId = "568",
artistId = "505", type = "music") artistId = "505", type = "music")

View File

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

View File

@ -33,18 +33,20 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
artistList.size `should equal to` 1 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.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",
title = "Always Outnumbered, Never Outgunned", isDir = true, title = "Always Outnumbered, Never Outgunned",
album = "Always Outnumbered, Never Outgunned", artist = "The Prodigy", album = "Always Outnumbered, Never Outgunned", artist = "The Prodigy",
year = 2004, genre = "Electronic", coverArt = "8867", playCount = 0, year = 2004, genre = "Electronic", coverArt = "8867", playCount = 0,
created = parseDate("2016-10-23T20:57:27.000Z")) created = parseDate("2016-10-23T20:57:27.000Z"))
songList.size `should equal to` 1 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", title = "You'll Be Under My Wheels", album = "Need for Speed Most Wanted",
artist = "The Prodigy", track = 17, year = 2005, genre = "Rap", artist = "The Prodigy", track = 17, year = 2005, genre = "Rap",
coverArt = "5766", size = 5607024, contentType = "audio/mpeg", coverArt = "5766", size = 5607024, contentType = "audio/mpeg",
suffix = "mp3", duration = 233, bitRate = 192, suffix = "mp3", duration = 233, bitRate = 192,
path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels.mp3", path = "Compilations/Need for Speed Most Wanted/17 You'll Be Under My Wheels" +
".mp3",
isVideo = false, playCount = 0, discNumber = 1, isVideo = false, playCount = 0, discNumber = 1,
created = parseDate("2016-10-23T20:09:02.000Z"), created = parseDate("2016-10-23T20:09:02.000Z"),
albumId = "568", artistId = "505", type = "music") albumId = "568", artistId = "505", type = "music")

View File

@ -40,7 +40,8 @@ class VersionInterceptorTest : BaseInterceptorTest() {
client.newCall(createRequest {}).execute() client.newCall(createRequest {}).execute()
(interceptor as VersionInterceptor).protocolVersion `should equal` SubsonicAPIVersions.V1_13_0 (interceptor as VersionInterceptor)
.protocolVersion `should equal` SubsonicAPIVersions.V1_13_0
} }
@Test @Test

View File

@ -271,7 +271,9 @@ internal class ApiVersionCheckWrapper(
return api.getBookmarks() return api.getBookmarks()
} }
override fun createBookmark(id: String, position: Long, comment: String?): Call<SubsonicResponse> { override fun createBookmark(id: String,
position: Long,
comment: String?): Call<SubsonicResponse> {
checkVersion(V1_9_0) checkVersion(V1_9_0)
return api.createBookmark(id, position, comment) return api.createBookmark(id, position, comment)
} }

View File

@ -127,7 +127,8 @@ interface SubsonicAPIDefinition {
@Query("comment") comment: String? = null, @Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null, @Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null, @Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null): Call<SubsonicResponse> @Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null):
Call<SubsonicResponse>
@GET("getPodcasts.view") @GET("getPodcasts.view")
fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null, fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@ -143,35 +144,39 @@ interface SubsonicAPIDefinition {
@Query("submission") submission: Boolean? = null): Call<SubsonicResponse> @Query("submission") submission: Boolean? = null): Call<SubsonicResponse>
@GET("getAlbumList.view") @GET("getAlbumList.view")
fun getAlbumList(@Query("type") type: AlbumListType, fun getAlbumList(
@Query("size") size: Int? = null, @Query("type") type: AlbumListType,
@Query("offset") offset: Int? = null, @Query("size") size: Int? = null,
@Query("fromYear") fromYear: Int? = null, @Query("offset") offset: Int? = null,
@Query("toYear") toYear: Int? = null, @Query("fromYear") fromYear: Int? = null,
@Query("genre") genre: String? = null, @Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse> @Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse>
@GET("getAlbumList2.view") @GET("getAlbumList2.view")
fun getAlbumList2(@Query("type") type: AlbumListType, fun getAlbumList2(
@Query("size") size: Int? = null, @Query("type") type: AlbumListType,
@Query("offset") offset: Int? = null, @Query("size") size: Int? = null,
@Query("fromYear") fromYear: Int? = null, @Query("offset") offset: Int? = null,
@Query("toYear") toYear: Int? = null, @Query("fromYear") fromYear: Int? = null,
@Query("genre") genre: String? = null, @Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response> @Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response>
@GET("getRandomSongs.view") @GET("getRandomSongs.view")
fun getRandomSongs(@Query("size") size: Int? = null, fun getRandomSongs(
@Query("genre") genre: String? = null, @Query("size") size: Int? = null,
@Query("fromYear") fromYear: Int? = null, @Query("genre") genre: String? = null,
@Query("toYear") toYear: Int? = null, @Query("fromYear") fromYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse> @Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse>
@GET("getStarred.view") @GET("getStarred.view")
fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse> fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse>
@GET("getStarred2.view") @GET("getStarred2.view")
fun getStarred2(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse> fun getStarred2(
@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse>
@Streaming @Streaming
@GET("getCoverArt.view") @GET("getCoverArt.view")

View File

@ -55,7 +55,8 @@ enum class SubsonicAPIVersions(val subsonicVersions: String, val restApiVersion:
} }
class SubsonicAPIVersionsDeserializer : JsonDeserializer<SubsonicAPIVersions>() { class SubsonicAPIVersionsDeserializer : JsonDeserializer<SubsonicAPIVersions>() {
override fun deserialize(p: JsonParser, ctxt: DeserializationContext?): SubsonicAPIVersions { override fun deserialize(p: JsonParser,
ctxt: DeserializationContext?): SubsonicAPIVersions {
if (p.currentName != "version") { if (p.currentName != "version") {
throw JsonParseException(p, "Not valid token for API version!") throw JsonParseException(p, "Not valid token for API version!")
} }

View File

@ -36,6 +36,6 @@ internal class RangeHeaderInterceptor : Interceptor {
// to avoid the thrashing effect seen when offset is combined with transcoding/downsampling // to avoid the thrashing effect seen when offset is combined with transcoding/downsampling
// on the server. In that case, the server uses a long time before sending any data, // on the server. In that case, the server uses a long time before sending any data,
// causing the client to time out. // causing the client to time out.
private fun getReadTimeout(offset: Int) private fun getReadTimeout(offset: Int) =
= (SOCKET_READ_TIMEOUT_DOWNLOAD + offset * TIMEOUT_MILLIS_PER_OFFSET_BYTE).toInt() (SOCKET_READ_TIMEOUT_DOWNLOAD + offset * TIMEOUT_MILLIS_PER_OFFSET_BYTE).toInt()
} }

View File

@ -2,6 +2,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
data class SearchResult(val offset: Int = 0, data class SearchResult(
val totalHits: Int = 0, val offset: Int = 0,
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList()) val totalHits: Int = 0,
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList())

View File

@ -16,4 +16,5 @@ class GetPlaylistsResponse(status: Status,
get() = playlistsWrapper.playlistList get() = playlistsWrapper.playlistList
} }
private class PlaylistsWrapper(@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList()) private class PlaylistsWrapper(
@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList())

View File

@ -5,8 +5,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class SearchTwoResponse(status: Status, class SearchTwoResponse(
version: SubsonicAPIVersions, status: Status,
error: SubsonicError?, version: SubsonicAPIVersions,
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult()) error: SubsonicError?,
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error) : SubsonicResponse(status, version, error)

View File

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

View File

@ -15,9 +15,9 @@ import java.util.Calendar
class APIAlbumConverterTest { class APIAlbumConverterTest {
@Test @Test
fun `Should convert Album to domain entity`() { fun `Should convert Album to domain entity`() {
val entity = Album(id = "387", name = "some-name", coverArt = "asdas", artist = "some-artist", val entity = Album(id = "387", name = "some-name", coverArt = "asdas",
artistId = "390", songCount = 12, duration = 841, created = Calendar.getInstance(), artist = "some-artist", artistId = "390", songCount = 12, duration = 841,
year = 2017, genre = "some-genre") created = Calendar.getInstance(), year = 2017, genre = "some-genre")
val convertedEntity = entity.toDomainEntity() val convertedEntity = entity.toDomainEntity()

View File

@ -27,7 +27,8 @@ class APIArtistConverterTest {
@Test @Test
fun `Should convert Artist entity to domain MusicDirectory entity`() { fun `Should convert Artist entity to domain MusicDirectory entity`() {
val entity = Artist(id = "101", name = "artist-name", coverArt = "some-art", albumCount = 10, val entity = Artist(id = "101", name = "artist-name", coverArt = "some-art",
albumCount = 10,
albumsList = listOf(Album(id = "562", name = "some-name", coverArt = "zzz", albumsList = listOf(Album(id = "562", name = "some-name", coverArt = "zzz",
artist = "artist-name", artistId = "256", songCount = 10, duration = 345, artist = "artist-name", artistId = "256", songCount = 10, duration = 345,
created = Calendar.getInstance(), year = 2011, genre = "Math Rock"))) created = Calendar.getInstance(), year = 2011, genre = "Math Rock")))

View File

@ -16,8 +16,8 @@ class APIIndexesConverterTest {
@Test @Test
fun `Should convert Indexes entity`() { fun `Should convert Indexes entity`() {
val artistsA = listOf( val artistsA = listOf(
Artist(id ="4", name = "AC/DC"), Artist(id = "4", name = "AC/DC"),
Artist(id ="45", name = "ABBA")) Artist(id = "45", name = "ABBA"))
val artistsT = listOf( val artistsT = listOf(
Artist(id = "10", name = "Taproot"), Artist(id = "10", name = "Taproot"),
Artist(id = "12", name = "Teebee")) Artist(id = "12", name = "Teebee"))

View File

@ -37,7 +37,8 @@ class APIMusicDirectoryConverterTest {
transcodedContentType = "some-transcoded-content-type", transcodedContentType = "some-transcoded-content-type",
transcodedSuffix = "some-transcoded-suffix", duration = 11, bitRate = 256, transcodedSuffix = "some-transcoded-suffix", duration = 11, bitRate = 256,
path = "some-path", isDir = true, isVideo = true, playCount = 323, discNumber = 2, path = "some-path", isDir = true, isVideo = true, playCount = 323, discNumber = 2,
created = Calendar.getInstance(), type = "some-type", starred = Calendar.getInstance()) created = Calendar.getInstance(), type = "some-type",
starred = Calendar.getInstance())
val convertedEntity = entity.toDomainEntity() val convertedEntity = entity.toDomainEntity()