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
|
2017-09-02 19:40:32 +02:00
|
|
|
import org.amshove.kluent.`should equal`
|
|
|
|
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
|
|
|
*/
|
|
|
|
class APIArtistConverterTest {
|
|
|
|
@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
|
|
|
|
|
|
|
val convertedEntity = entity.toDomainEntity()
|
|
|
|
|
|
|
|
with(convertedEntity) {
|
2018-02-22 22:30:39 +01:00
|
|
|
id `should equal` entity.id
|
|
|
|
name `should equal` 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
|
|
|
|
|
|
|
val convertedEntity = entity.toMusicDirectoryDomainEntity()
|
|
|
|
|
|
|
|
with(convertedEntity) {
|
2018-02-24 22:19:34 +01:00
|
|
|
name `should equal` entity.name
|
|
|
|
getAllChild() `should equal` entity.albumsList
|
2020-06-13 19:04:31 +02:00
|
|
|
.map { it.toDomainEntity() }.toMutableList()
|
2017-09-02 19:40:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|