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
|
|
|
|
2020-06-13 19:04:31 +02:00
|
|
|
import java.util.Calendar
|
2021-05-07 15:36:11 +02: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.Album
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Artist
|
|
|
|
|
|
|
|
/**
|
2017-12-16 20:10:25 +01:00
|
|
|
* Unit test for extension functions in APIArtistConverter.kt file.
|
2017-09-02 19:40:32 +02:00
|
|
|
*/
|
2022-07-04 17:31:58 +02:00
|
|
|
class APIArtistConverterTest : BaseTest() {
|
2017-09-02 19:40:32 +02:00
|
|
|
@Test
|
|
|
|
fun `Should convert artist entity`() {
|
2017-12-16 19:50:57 +01:00
|
|
|
val entity = Artist(id = "10", name = "artist-name", starred = Calendar.getInstance())
|
2017-09-02 19:40:32 +02:00
|
|
|
|
2022-07-04 17:31:58 +02:00
|
|
|
val convertedEntity = entity.toDomainEntity(serverId)
|
2017-09-02 19:40:32 +02:00
|
|
|
|
|
|
|
with(convertedEntity) {
|
2021-05-07 15:36:11 +02:00
|
|
|
id `should be equal to` entity.id
|
|
|
|
name `should be equal to` entity.name
|
2017-09-02 19:40:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should convert Artist entity to domain MusicDirectory entity`() {
|
2020-06-13 19:04:31 +02:00
|
|
|
val entity = Artist(
|
|
|
|
id = "101", name = "artist-name", coverArt = "some-art",
|
|
|
|
albumCount = 10,
|
|
|
|
albumsList = listOf(
|
|
|
|
Album(
|
|
|
|
id = "562", name = "some-name", coverArt = "zzz",
|
|
|
|
artist = "artist-name", artistId = "256", songCount = 10, duration = 345,
|
|
|
|
created = Calendar.getInstance(), year = 2011, genre = "Math Rock"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2017-09-02 19:40:32 +02:00
|
|
|
|
2022-07-04 17:31:58 +02:00
|
|
|
val convertedEntity = entity.toMusicDirectoryDomainEntity(serverId)
|
2017-09-02 19:40:32 +02:00
|
|
|
|
|
|
|
with(convertedEntity) {
|
2021-05-07 15:36:11 +02:00
|
|
|
name `should be equal to` entity.name
|
2021-11-26 17:03:33 +01:00
|
|
|
getChildren() `should be equal to` entity.albumsList
|
2022-07-04 17:31:58 +02:00
|
|
|
.map { it.toDomainEntity(serverId) }.toMutableList()
|
2017-09-02 19:40:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|