diff --git a/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClientTest.kt b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClientTest.kt index b8ee2385..71f58c48 100644 --- a/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClientTest.kt +++ b/subsonic-api/src/integrationTest/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClientTest.kt @@ -30,7 +30,7 @@ import java.util.TimeZone /** * Integration test for [SubsonicAPIClient] class. */ -@Suppress("TooManyFunctions") +@Suppress("TooManyFunctions", "LargeClass") class SubsonicAPIClientTest { companion object { const val USERNAME = "some-user" @@ -154,7 +154,6 @@ class SubsonicAPIClientTest { @Test fun `Should parse get indexes ok response`() { - // check for shortcut parsing enqueueResponse("get_indexes_ok.json") val response = client.api.getIndexes(null, null).execute() @@ -164,7 +163,10 @@ class SubsonicAPIClientTest { with(response.body().indexes) { lastModified `should equal` 1491069027523 ignoredArticles `should equal` "The El La Los Las Le Les" - shortcuts `should be` emptyList() + shortcutList `should equal` listOf( + Artist(889L, "podcasts", null), + Artist(890L, "audiobooks", null) + ) indexList `should equal` mutableListOf( Index("A", listOf( Artist(50L, "Ace Of Base", parseDate("2017-04-02T20:16:29.815Z")), @@ -225,7 +227,7 @@ class SubsonicAPIClientTest { lastModified `should equal to` 0 ignoredArticles `should equal to` "" indexList.size `should equal to` 0 - shortcuts.size `should equal to` 0 + shortcutList.size `should equal to` 0 } } diff --git a/subsonic-api/src/integrationTest/resources/get_indexes_ok.json b/subsonic-api/src/integrationTest/resources/get_indexes_ok.json index b604c939..758262f1 100644 --- a/subsonic-api/src/integrationTest/resources/get_indexes_ok.json +++ b/subsonic-api/src/integrationTest/resources/get_indexes_ok.json @@ -5,6 +5,14 @@ "indexes" : { "lastModified" : 1491069027523, "ignoredArticles" : "The El La Los Las Le Les", + "shortcut" : [ { + "id" : "889", + "name" : "podcasts" + }, + { + "id" : "890", + "name" : "audiobooks" + } ], "index" : [ { "name" : "A", "artist" : [ { diff --git a/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/models/Indexes.kt b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/models/Indexes.kt index ae889d6a..bd46cea4 100644 --- a/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/models/Indexes.kt +++ b/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/models/Indexes.kt @@ -6,4 +6,5 @@ data class Indexes(val lastModified: Long = 0, val ignoredArticles: String = "", @JsonProperty("index") val indexList: List = emptyList(), - val shortcuts: List = emptyList()) + @JsonProperty("shortcut") + val shortcutList: List = emptyList()) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/SubsonicAPIConverter.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/SubsonicAPIConverter.kt index 3d567ba0..5851e96b 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/SubsonicAPIConverter.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/SubsonicAPIConverter.kt @@ -16,7 +16,7 @@ fun List.toDomainEntityList(): List = this.map { it.toDomainEntity() } fun APIIndexes.toDomainEntity(): Indexes = Indexes(this.lastModified, this.ignoredArticles, - this.shortcuts.foldIndexToArtistList(), this.indexList.foldIndexToArtistList()) + this.shortcutList.map { it.toDomainEntity() }, this.indexList.foldIndexToArtistList()) private fun List.foldIndexToArtistList(): List = this.fold(listOf(), { acc, index -> acc + index.artists.map { it.toDomainEntity() } @@ -25,4 +25,4 @@ private fun List.foldIndexToArtistList(): List = this.fold(listOf fun APIArtist.toDomainEntity(): Artist = Artist().apply { id = this@toDomainEntity.id.toString() name = this@toDomainEntity.name -} \ No newline at end of file +} diff --git a/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APIConverterTest.kt b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APIConverterTest.kt index 8edec539..50ee5da8 100644 --- a/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APIConverterTest.kt +++ b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APIConverterTest.kt @@ -64,7 +64,7 @@ class APIConverterTest { val entity = createIndexes(154, "Le Tre Ze", listOf( createIndex("A", artistsA), createIndex("T", artistsT) - ), emptyList()) + ), artistsA) val convertedEntity = entity.toDomainEntity() @@ -74,7 +74,7 @@ class APIConverterTest { ignoredArticles `should equal to` entity.ignoredArticles artists.size `should equal to` expectedArtists.size artists `should equal` expectedArtists - shortcuts `should equal` emptyList() + shortcuts `should equal` artistsA.map { it.toDomainEntity() }.toMutableList() } } @@ -91,6 +91,6 @@ class APIConverterTest { lastModified: Long = 0, ignoredArticles: String, indexList: List = emptyList(), - shortcuts: List = emptyList()): Indexes + shortcuts: List = emptyList()): Indexes = Indexes(lastModified, ignoredArticles, indexList, shortcuts) }