2017-09-02 19:40:32 +02:00
|
|
|
@file:Suppress("IllegalIdentifier")
|
|
|
|
|
2018-02-17 20:36:19 +01:00
|
|
|
package org.moire.ultrasonic.domain
|
2017-09-02 19:40:32 +02:00
|
|
|
|
2018-03-24 19:30:03 +01:00
|
|
|
import org.amshove.kluent.`should be equal to`
|
2017-09-02 19:40:32 +02:00
|
|
|
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.Indexes
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit tests for extension functions in [APIIndexesConverter.kt].
|
|
|
|
*/
|
2021-06-20 16:31:08 +02:00
|
|
|
class APIIndexConverterTest {
|
2017-09-02 19:40:32 +02:00
|
|
|
@Test
|
|
|
|
fun `Should convert Indexes entity`() {
|
|
|
|
val artistsA = listOf(
|
2020-06-13 19:04:31 +02:00
|
|
|
Artist(id = "4", name = "AC/DC"),
|
|
|
|
Artist(id = "45", name = "ABBA")
|
|
|
|
)
|
2017-09-02 19:40:32 +02:00
|
|
|
val artistsT = listOf(
|
2020-06-13 19:04:31 +02:00
|
|
|
Artist(id = "10", name = "Taproot"),
|
|
|
|
Artist(id = "12", name = "Teebee")
|
|
|
|
)
|
|
|
|
val entity = Indexes(
|
|
|
|
lastModified = 154, ignoredArticles = "Le Tre Ze",
|
|
|
|
indexList = listOf(
|
2017-09-02 19:40:32 +02:00
|
|
|
Index(name = "A", artists = artistsA),
|
|
|
|
Index(name = "T", artists = artistsT)
|
2020-06-13 19:04:31 +02:00
|
|
|
),
|
|
|
|
shortcutList = artistsA
|
|
|
|
)
|
2017-09-02 19:40:32 +02:00
|
|
|
|
2021-06-23 17:09:33 +02:00
|
|
|
val convertedEntity = entity.toArtistList()
|
2017-09-02 19:40:32 +02:00
|
|
|
|
|
|
|
val expectedArtists = (artistsA + artistsT).map { it.toDomainEntity() }.toMutableList()
|
|
|
|
with(convertedEntity) {
|
2021-06-20 16:31:08 +02:00
|
|
|
size `should be equal to` expectedArtists.size
|
|
|
|
this `should be equal to` expectedArtists
|
2017-09-02 19:40:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|