mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-29 15:11:34 +03:00
Update kotlin and android dependencies.
This commit is contained in:
parent
429f302f7e
commit
f686ebfb16
@ -1,14 +1,14 @@
|
|||||||
ext.versions = [
|
ext.versions = [
|
||||||
minSdk : 14,
|
minSdk : 14,
|
||||||
targetSdk : 22,
|
targetSdk : 22,
|
||||||
compileSdk : 22,
|
compileSdk : 26,
|
||||||
|
|
||||||
buildTools : "25.0.2",
|
buildTools : "25.0.3",
|
||||||
androidTools : "2.3.0",
|
androidTools : "2.3.3",
|
||||||
|
|
||||||
androidSupport : "22.2.1",
|
androidSupport : "22.2.1",
|
||||||
|
|
||||||
kotlin : "1.1.0",
|
kotlin : "1.1.2-5",
|
||||||
|
|
||||||
retrofit : "2.1.0",
|
retrofit : "2.1.0",
|
||||||
jackson : "2.8.7",
|
jackson : "2.8.7",
|
||||||
|
@ -3,11 +3,14 @@ package org.moire.ultrasonic.api.subsonic
|
|||||||
import okhttp3.mockwebserver.MockResponse
|
import okhttp3.mockwebserver.MockResponse
|
||||||
import okio.Okio
|
import okio.Okio
|
||||||
import org.amshove.kluent.`should be`
|
import org.amshove.kluent.`should be`
|
||||||
|
import org.amshove.kluent.`should contain`
|
||||||
import org.amshove.kluent.`should equal`
|
import org.amshove.kluent.`should equal`
|
||||||
import org.amshove.kluent.`should not be`
|
import org.amshove.kluent.`should not be`
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.Artist
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.Index
|
||||||
import org.moire.ultrasonic.api.subsonic.models.License
|
import org.moire.ultrasonic.api.subsonic.models.License
|
||||||
import org.moire.ultrasonic.api.subsonic.models.MusicFolder
|
import org.moire.ultrasonic.api.subsonic.models.MusicFolder
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
||||||
@ -97,6 +100,77 @@ class SubsonicAPITest {
|
|||||||
response.musicFolders `should be` null
|
response.musicFolders `should be` null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should parse get indexes ok response`() {
|
||||||
|
// TODO: check for shortcut parsing
|
||||||
|
enqueueResponse("get_indexes_ok.json")
|
||||||
|
|
||||||
|
val response = api.getApi().getIndexes(null, null).execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
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"
|
||||||
|
shortcuts `should be` null
|
||||||
|
indexList `should equal` mutableListOf(
|
||||||
|
Index("A", listOf(
|
||||||
|
Artist(50L, "Ace Of Base", parseDate("2017-04-02T20:16:29.815Z")),
|
||||||
|
Artist(379L, "A Perfect Circle", null)
|
||||||
|
)),
|
||||||
|
Index("H", listOf(
|
||||||
|
Artist(299, "Haddaway", null),
|
||||||
|
Artist(297, "Halestorm", null)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should add music folder id as a query param for getIndexes api call`() {
|
||||||
|
enqueueResponse("get_indexes_ok.json")
|
||||||
|
val musicFolderId = 9L
|
||||||
|
|
||||||
|
api.getApi().getIndexes(musicFolderId, null).execute()
|
||||||
|
|
||||||
|
with(mockWebServerRule.mockWebServer.takeRequest()) {
|
||||||
|
requestLine `should contain` "musicFolderId=$musicFolderId"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should add ifModifiedSince as a query param for getIndexes api call`() {
|
||||||
|
enqueueResponse("get_indexes_ok.json")
|
||||||
|
val ifModifiedSince = System.currentTimeMillis()
|
||||||
|
|
||||||
|
api.getApi().getIndexes(null, ifModifiedSince).execute()
|
||||||
|
|
||||||
|
with(mockWebServerRule.mockWebServer.takeRequest()) {
|
||||||
|
requestLine `should contain` "ifModifiedSince=$ifModifiedSince"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should add both params to query for getIndexes api call`() {
|
||||||
|
enqueueResponse("get_indexes_ok.json")
|
||||||
|
val musicFolderId = 110L
|
||||||
|
val ifModifiedSince = System.currentTimeMillis()
|
||||||
|
|
||||||
|
api.getApi().getIndexes(musicFolderId, ifModifiedSince).execute()
|
||||||
|
|
||||||
|
with(mockWebServerRule.mockWebServer.takeRequest()) {
|
||||||
|
requestLine `should contain` "musicFolderId=$musicFolderId"
|
||||||
|
requestLine `should contain` "ifModifiedSince=$ifModifiedSince"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should parse get indexes error response`() {
|
||||||
|
val response = checkErrorCallParsed { api.getApi().getIndexes(null, null).execute() }
|
||||||
|
|
||||||
|
response.indexes `should be` null
|
||||||
|
}
|
||||||
|
|
||||||
private fun enqueueResponse(resourceName: String) {
|
private fun enqueueResponse(resourceName: String) {
|
||||||
mockWebServerRule.mockWebServer.enqueue(MockResponse()
|
mockWebServerRule.mockWebServer.enqueue(MockResponse()
|
||||||
.setBody(loadJsonResponse(resourceName)))
|
.setBody(loadJsonResponse(resourceName)))
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"subsonic-response" : {
|
||||||
|
"status" : "ok",
|
||||||
|
"version" : "1.13.0",
|
||||||
|
"indexes" : {
|
||||||
|
"lastModified" : 1491069027523,
|
||||||
|
"ignoredArticles" : "The El La Los Las Le Les",
|
||||||
|
"index" : [ {
|
||||||
|
"name" : "A",
|
||||||
|
"artist" : [ {
|
||||||
|
"id" : "50",
|
||||||
|
"name" : "Ace Of Base",
|
||||||
|
"starred" : "2017-04-02T20:16:29.815Z"
|
||||||
|
}, {
|
||||||
|
"id" : "379",
|
||||||
|
"name" : "A Perfect Circle"
|
||||||
|
} ]
|
||||||
|
}, {
|
||||||
|
"name" : "H",
|
||||||
|
"artist" : [ {
|
||||||
|
"id" : "299",
|
||||||
|
"name" : "Haddaway"
|
||||||
|
}, {
|
||||||
|
"id" : "297",
|
||||||
|
"name" : "Halestorm"
|
||||||
|
} ]
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,17 @@
|
|||||||
package org.moire.ultrasonic.api.subsonic
|
package org.moire.ultrasonic.api.subsonic
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.api.subsonic.response.GetIndexesResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse
|
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.Query
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO
|
* Subsonic API calls.
|
||||||
|
*
|
||||||
|
* For methods description see [http://www.subsonic.org/pages/api.jsp].
|
||||||
*/
|
*/
|
||||||
interface SubsonicAPIDefinition {
|
interface SubsonicAPIDefinition {
|
||||||
@GET("ping.view")
|
@GET("ping.view")
|
||||||
@ -18,4 +22,8 @@ interface SubsonicAPIDefinition {
|
|||||||
|
|
||||||
@GET("getMusicFolders.view")
|
@GET("getMusicFolders.view")
|
||||||
fun getMusicFolders(): Call<MusicFoldersResponse>
|
fun getMusicFolders(): Call<MusicFoldersResponse>
|
||||||
|
|
||||||
|
@GET("getIndexes.view")
|
||||||
|
fun getIndexes(@Query("musicFolderId") musicFolderId: Long?,
|
||||||
|
@Query("ifModifiedSince") ifModifiedSince: Long?): Call<GetIndexesResponse>
|
||||||
}
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
data class Artist(val id: Long,
|
||||||
|
val name: String,
|
||||||
|
val starred: Calendar?)
|
@ -0,0 +1,7 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
|
data class Index(val name: String,
|
||||||
|
@JsonProperty("artist")
|
||||||
|
val artists: List<Artist>)
|
@ -0,0 +1,9 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.models
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
|
data class Indexes(val lastModified: Long,
|
||||||
|
val ignoredArticles: String?,
|
||||||
|
@JsonProperty("index")
|
||||||
|
val indexList: List<Index>,
|
||||||
|
val shortcuts: List<Index>?)
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.response
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.Indexes
|
||||||
|
|
||||||
|
class GetIndexesResponse(status: Status,
|
||||||
|
version: SubsonicAPIVersions,
|
||||||
|
error: SubsonicError?,
|
||||||
|
val indexes: Indexes?) :
|
||||||
|
SubsonicResponse(status, version, error)
|
Loading…
x
Reference in New Issue
Block a user