mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-28 17:37:39 +01:00
Update Retrofit to 2.4.0 version.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
ce9edae390
commit
61b92bee39
@ -18,7 +18,7 @@ ext.versions = [
|
||||
|
||||
kotlin : "1.2.31",
|
||||
|
||||
retrofit : "2.1.0",
|
||||
retrofit : "2.4.0",
|
||||
jackson : "2.9.0",
|
||||
okhttp : "3.9.0",
|
||||
semver : "1.0.0",
|
||||
|
@ -64,11 +64,11 @@ fun <T : SubsonicResponse> checkErrorCallParsed(mockWebServerRule: MockWebServer
|
||||
val response = apiRequest()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body()) {
|
||||
with(response.body()!!) {
|
||||
status `should be` SubsonicResponse.Status.ERROR
|
||||
error `should be` SubsonicError.RequestedDataWasNotFound
|
||||
}
|
||||
return response.body()
|
||||
return response.body()!!
|
||||
}
|
||||
|
||||
fun SubsonicResponse.assertBaseResponseOk() {
|
||||
|
@ -26,8 +26,8 @@ class SubsonicApiCreateShareTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.createShare(listOf("some-id")).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().shares.size `should equal to` 1
|
||||
with(response.body().shares[0]) {
|
||||
response.body()!!.shares.size `should equal to` 1
|
||||
with(response.body()!!.shares[0]) {
|
||||
id `should equal to` "0"
|
||||
url `should equal to` "https://subsonic.com/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1NiJ9." +
|
||||
"eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8hJ692" +
|
||||
|
@ -150,7 +150,7 @@ class SubsonicApiErrorsTest : SubsonicAPIClientTest() {
|
||||
}
|
||||
|
||||
private fun Response<SubsonicResponse>.assertError(expectedError: SubsonicError) =
|
||||
with(body()) {
|
||||
with(body()!!) {
|
||||
error `should not be` null
|
||||
error `should equal` expectedError
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class SubsonicApiGetAlbumList2Test : SubsonicAPIClientTest() {
|
||||
val response = client.api.getAlbumList2(STARRED).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().albumList) {
|
||||
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,
|
||||
|
@ -27,7 +27,7 @@ class SubsonicApiGetAlbumListRequestTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getAlbumList(BY_GENRE).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().albumList) {
|
||||
with(response.body()!!.albumList) {
|
||||
size `should equal to` 2
|
||||
this[1] `should equal` MusicDirectoryChild(id = "9997", parent = "9996", isDir = true,
|
||||
title = "Endless Forms Most Beautiful", album = "Endless Forms Most Beautiful",
|
||||
|
@ -38,7 +38,7 @@ class SubsonicApiGetAlbumTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getAlbum("512").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().album) {
|
||||
with(response.body()!!.album) {
|
||||
id `should equal to` "618"
|
||||
name `should equal to` "Black Ice"
|
||||
artist `should equal to` "AC/DC"
|
||||
|
@ -38,7 +38,7 @@ class SubsonicApiGetArtistTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getArtist("100").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().artist) {
|
||||
with(response.body()!!.artist) {
|
||||
id `should equal to` "362"
|
||||
name `should equal to` "AC/DC"
|
||||
coverArt `should equal to` "ar-362"
|
||||
|
@ -29,7 +29,7 @@ class SubsonicApiGetArtistsTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getArtists(null).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().indexes) {
|
||||
with(response.body()!!.indexes) {
|
||||
lastModified `should equal to` 0L
|
||||
ignoredArticles `should equal to` "The El La Los Las Le Les"
|
||||
shortcutList `should equal` emptyList()
|
||||
|
@ -25,8 +25,8 @@ class SubsonicApiGetBookmarksTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getBookmarks().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().bookmarkList.size `should equal to` 1
|
||||
with(response.body().bookmarkList[0]) {
|
||||
response.body()!!.bookmarkList.size `should equal to` 1
|
||||
with(response.body()!!.bookmarkList[0]) {
|
||||
position `should equal to` 107914
|
||||
username `should equal to` "CaptainEurope"
|
||||
comment `should equal to` "Look at this"
|
||||
|
@ -25,7 +25,7 @@ class SubsonicApiGetChatMessagesTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getChatMessages().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().chatMessages) {
|
||||
with(response.body()!!.chatMessages) {
|
||||
size `should equal to` 2
|
||||
this[0] `should equal` ChatMessage(username = "sindre", time = 1269771845310,
|
||||
message = "Sindre was here")
|
||||
|
@ -25,7 +25,7 @@ class SubsonicApiGetGenresTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getGenres().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().genresList) {
|
||||
with(response.body()!!.genresList) {
|
||||
size `should equal to` 5
|
||||
this[0] `should equal` Genre(1186, 103, "Rock")
|
||||
this[1] `should equal` Genre(896, 72, "Electronic")
|
||||
|
@ -18,8 +18,8 @@ class SubsonicApiGetIndexesTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getIndexes(null, null).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().indexes `should not be` null
|
||||
with(response.body().indexes) {
|
||||
response.body()!!.indexes `should not be` null
|
||||
with(response.body()!!.indexes) {
|
||||
lastModified `should equal` 1491069027523
|
||||
ignoredArticles `should equal` "The El La Los Las Le Les"
|
||||
shortcutList `should equal` listOf(
|
||||
|
@ -16,7 +16,7 @@ class SubsonicApiGetLicenseTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getLicense().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body()) {
|
||||
with(response.body()!!) {
|
||||
assertBaseResponseOk()
|
||||
license `should equal` License(valid = true,
|
||||
trialExpires = parseDate("2016-11-23T20:17:15.206Z"),
|
||||
|
@ -21,7 +21,7 @@ class SubsonicApiGetLyricsTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getLyrics().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().lyrics) {
|
||||
with(response.body()!!.lyrics) {
|
||||
artist `should equal to` "Amorphis"
|
||||
title `should equal to` "Alone"
|
||||
text `should equal to` "Tear dimmed rememberance\nIn a womb of time\nBreath upon " +
|
||||
|
@ -40,8 +40,8 @@ class SubsonicApiGetMusicDirectoryTest : SubsonicAPIClientTest() {
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
|
||||
response.body().musicDirectory `should not be` null
|
||||
with(response.body().musicDirectory) {
|
||||
response.body()!!.musicDirectory `should not be` null
|
||||
with(response.body()!!.musicDirectory) {
|
||||
id `should equal to` "4836"
|
||||
parent `should equal to` "300"
|
||||
name `should equal` "12 Stones"
|
||||
|
@ -15,7 +15,7 @@ class SubsonicApiGetMusicFoldersTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getMusicFolders().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body()) {
|
||||
with(response.body()!!) {
|
||||
assertBaseResponseOk()
|
||||
musicFolders `should equal` listOf(
|
||||
MusicFolder("0", "Music"),
|
||||
|
@ -28,7 +28,7 @@ class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getPlaylist("4").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().playlist) {
|
||||
with(response.body()!!.playlist) {
|
||||
id `should equal to` "0"
|
||||
name `should equal to` "Aug 27, 2017 11:17 AM"
|
||||
owner `should equal to` "admin"
|
||||
|
@ -27,7 +27,7 @@ class SubsonicApiGetPlaylistsTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getPlaylists().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().playlists) {
|
||||
with(response.body()!!.playlists) {
|
||||
size `should equal to` 1
|
||||
this[0] `should equal` Playlist(id = "0", name = "Aug 27, 2017 11:17 AM",
|
||||
owner = "admin", public = false, songCount = 16, duration = 3573,
|
||||
|
@ -27,7 +27,7 @@ class SubsonicApiGetPodcastsTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getPodcasts().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
val podcastChannelsList = response.body().podcastChannels
|
||||
val podcastChannelsList = response.body()!!.podcastChannels
|
||||
podcastChannelsList.size `should equal to` 1
|
||||
with(podcastChannelsList[0]) {
|
||||
id `should equal to` "2"
|
||||
|
@ -25,7 +25,7 @@ class SubsonicApiGetRandomSongsTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getRandomSongs().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().songsList) {
|
||||
with(response.body()!!.songsList) {
|
||||
size `should equal to` 3
|
||||
this[1] `should equal` MusicDirectoryChild(id = "3061", parent = "3050", isDir = false,
|
||||
title = "Sure as Hell", album = "Who Are You Now?", artist = "This Providence",
|
||||
|
@ -25,8 +25,8 @@ class SubsonicApiGetSharesTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getShares().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().shares.size `should equal to` 1
|
||||
with(response.body().shares[0]) {
|
||||
response.body()!!.shares.size `should equal to` 1
|
||||
with(response.body()!!.shares[0]) {
|
||||
id `should equal to` "0"
|
||||
url `should equal to` "https://subsonic.com/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1" +
|
||||
"NiJ9.eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8" +
|
||||
|
@ -25,8 +25,8 @@ class SubsonicApiGetSongsByGenreTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getSongsByGenre("Trance").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().songsList.size `should equal to` 2
|
||||
with(response.body().songsList) {
|
||||
response.body()!!.songsList.size `should equal to` 2
|
||||
with(response.body()!!.songsList) {
|
||||
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,
|
||||
|
@ -27,7 +27,7 @@ class SubsonicApiGetStarred2Test : SubsonicAPIClientTest() {
|
||||
val response = client.api.getStarred2().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().starred2) {
|
||||
with(response.body()!!.starred2) {
|
||||
albumList `should equal` emptyList()
|
||||
artistList.size `should equal to` 1
|
||||
artistList[0] `should equal` Artist(id = "364", name = "Parov Stelar",
|
||||
|
@ -26,7 +26,7 @@ class SubsonicApiGetStarredTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getStarred().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().starred) {
|
||||
with(response.body()!!.starred) {
|
||||
albumList `should equal` emptyList()
|
||||
artistList.size `should equal to` 1
|
||||
artistList[0] `should equal` Artist(id = "364", name = "Parov Stelar",
|
||||
|
@ -25,7 +25,7 @@ class SubsonicApiGetUserTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getUser("some").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().user) {
|
||||
with(response.body()!!.user) {
|
||||
username `should equal to` "GodOfUniverse"
|
||||
email `should equal to` "some.mail@example.com"
|
||||
scrobblingEnabled `should equal to` false
|
||||
|
@ -25,7 +25,7 @@ class SubsonicApiGetVideosListTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.getVideos().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().videosList) {
|
||||
with(response.body()!!.videosList) {
|
||||
size `should equal to` 1
|
||||
this[0] `should equal` MusicDirectoryChild(id = "10402", parent = "10401",
|
||||
isDir = false, title = "MVI_0512", album = "Incoming", size = 21889646,
|
||||
|
@ -29,7 +29,7 @@ class SubsonicApiJukeboxControlTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.jukeboxControl(STATUS).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().jukebox) {
|
||||
with(response.body()!!.jukebox) {
|
||||
currentIndex `should equal to` 94
|
||||
playing `should equal to` true
|
||||
gain `should equal to` 0.32f
|
||||
@ -45,7 +45,7 @@ class SubsonicApiJukeboxControlTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.jukeboxControl(GET).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().jukebox) {
|
||||
with(response.body()!!.jukebox) {
|
||||
currentIndex `should equal to` 887
|
||||
playing `should equal to` false
|
||||
gain `should equal to` 0.88f
|
||||
|
@ -13,7 +13,7 @@ class SubsonicApiPingRequestTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.ping().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body()) {
|
||||
with(response.body()!!) {
|
||||
assertBaseResponseOk()
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class SubsonicApiSearchTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.search().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().searchResult) {
|
||||
with(response.body()!!.searchResult) {
|
||||
offset `should equal to` 10
|
||||
totalHits `should equal to` 53
|
||||
matchList.size `should equal to` 1
|
||||
|
@ -30,7 +30,7 @@ class SubsonicApiSearchThreeTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.search3("some-query").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().searchResult) {
|
||||
with(response.body()!!.searchResult) {
|
||||
artistList.size `should equal to` 1
|
||||
artistList[0] `should equal` Artist(id = "505", name = "The Prodigy",
|
||||
coverArt = "ar-505", albumCount = 5)
|
||||
|
@ -29,7 +29,7 @@ class SubsonicApiSearchTwoTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.search2("some-query").execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().searchResult) {
|
||||
with(response.body()!!.searchResult) {
|
||||
artistList.size `should equal to` 1
|
||||
artistList[0] `should equal` Artist(id = "522", name = "The Prodigy")
|
||||
albumList.size `should equal to` 1
|
||||
|
@ -15,7 +15,7 @@ class SubsonicApiStarTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.star().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().status `should be` SubsonicResponse.Status.OK
|
||||
response.body()?.status `should be` SubsonicResponse.Status.OK
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -15,7 +15,7 @@ class SubsonicApiUnstarTest : SubsonicAPIClientTest() {
|
||||
val response = client.api.unstar().execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
response.body().status `should be` SubsonicResponse.Status.OK
|
||||
response.body()?.status `should be` SubsonicResponse.Status.OK
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -139,14 +139,14 @@ class SubsonicAPIClient(baseUrl: String,
|
||||
val response = apiCall()
|
||||
return if (response.isSuccessful) {
|
||||
val responseBody = response.body()
|
||||
val contentType = responseBody.contentType()
|
||||
val contentType = responseBody?.contentType()
|
||||
if (contentType != null &&
|
||||
contentType.type().equals("application", true) &&
|
||||
contentType.subtype().equals("json", true)) {
|
||||
val error = jacksonMapper.readValue<SubsonicResponse>(responseBody.byteStream())
|
||||
StreamResponse(apiError = error.error, responseHttpCode = response.code())
|
||||
} else {
|
||||
StreamResponse(stream = responseBody.byteStream(),
|
||||
StreamResponse(stream = responseBody?.byteStream(),
|
||||
responseHttpCode = response.code())
|
||||
}
|
||||
} else {
|
||||
@ -165,7 +165,7 @@ class SubsonicAPIClient(baseUrl: String,
|
||||
val request = api.stream(id).execute()
|
||||
val url = request.raw().request().url().toString()
|
||||
if (request.isSuccessful) {
|
||||
request.body().close()
|
||||
request.body()?.close()
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class PasswordHexInterceptor(private val password: String) : Interceptor {
|
||||
override fun intercept(chain: Chain): Response {
|
||||
val originalRequest = chain.request()
|
||||
val updatedUrl = originalRequest.url().newBuilder()
|
||||
.addQueryParameter("p", passwordHex).build()
|
||||
.addEncodedQueryParameter("p", passwordHex).build()
|
||||
return chain.proceed(originalRequest.newBuilder().url(updatedUrl).build())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user