2017-11-10 21:01:32 +01:00
|
|
|
package org.moire.ultrasonic.api.subsonic
|
|
|
|
|
2018-03-24 19:30:03 +01:00
|
|
|
import org.amshove.kluent.`should be equal to`
|
2017-11-10 21:01:32 +01:00
|
|
|
import org.amshove.kluent.`should equal`
|
|
|
|
import org.junit.Test
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Integration test for [SubsonicAPIDefinition.getShares] call.
|
|
|
|
*/
|
|
|
|
class SubsonicApiGetSharesTest : SubsonicAPIClientTest() {
|
|
|
|
@Test
|
|
|
|
fun `Should handle error response`() {
|
|
|
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
|
|
|
client.api.getShares().execute()
|
|
|
|
}
|
|
|
|
|
|
|
|
response.shares `should equal` emptyList()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should handle ok response`() {
|
|
|
|
mockWebServerRule.enqueueResponse("get_shares_ok.json")
|
|
|
|
|
|
|
|
val response = client.api.getShares().execute()
|
|
|
|
|
|
|
|
assertResponseSuccessful(response)
|
2018-03-24 19:30:03 +01:00
|
|
|
response.body()!!.shares.size `should be equal to` 1
|
2018-03-24 18:57:18 +01:00
|
|
|
with(response.body()!!.shares[0]) {
|
2018-03-24 19:30:03 +01:00
|
|
|
id `should be equal to` "0"
|
|
|
|
url `should be equal to` "https://subsonic.com/ext/share/awdwo?jwt=eyJhbGciOiJIUzI1" +
|
2017-11-10 21:01:32 +01:00
|
|
|
"NiJ9.eyJwYXRoIjoiL2V4dC9zaGFyZS9hd2R3byIsImV4cCI6MTU0MTYyNjQzMX0.iy8dkt_ZZc8" +
|
|
|
|
"hJ692UxorHdHWFU2RB-fMCmCA4IJ_dTw"
|
2018-03-24 19:30:03 +01:00
|
|
|
username `should be equal to` "admin"
|
2017-11-10 21:01:32 +01:00
|
|
|
created `should equal` parseDate("2017-11-07T21:33:51.748Z")
|
|
|
|
expires `should equal` parseDate("2018-11-07T21:33:51.748Z")
|
|
|
|
lastVisited `should equal` parseDate("2018-11-07T21:33:51.748Z")
|
2018-03-24 19:30:03 +01:00
|
|
|
visitCount `should be equal to` 0
|
|
|
|
description `should be equal to` "Awesome link!"
|
|
|
|
items.size `should be equal to` 1
|
2017-12-16 21:28:18 +01:00
|
|
|
items[0] `should equal` MusicDirectoryChild(id = "4212", parent = "4186", isDir = false,
|
2017-11-10 21:01:32 +01:00
|
|
|
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"),
|
2017-12-16 21:28:18 +01:00
|
|
|
albumId = "388", artistId = "238", type = "music")
|
2017-11-10 21:01:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|