2017-11-18 21:34:03 +01:00
|
|
|
@file:Suppress("IllegalIdentifier")
|
|
|
|
|
2018-02-17 20:36:19 +01:00
|
|
|
package org.moire.ultrasonic.domain
|
2017-11-18 21:34:03 +01:00
|
|
|
|
2020-06-13 19:04:31 +02:00
|
|
|
import java.util.Calendar
|
2018-03-24 19:30:03 +01:00
|
|
|
import org.amshove.kluent.`should be equal to`
|
2017-11-18 21:34:03 +01:00
|
|
|
import org.junit.Test
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Bookmark
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit test for function that converts [Bookmark] api entity to domain.
|
|
|
|
*/
|
|
|
|
class APIBookmarkConverterTest {
|
|
|
|
@Test
|
|
|
|
fun `Should convert to domain entity`() {
|
2020-06-13 19:04:31 +02:00
|
|
|
val entity = Bookmark(
|
|
|
|
412313L, "Awesemo", "Nice", Calendar.getInstance(),
|
|
|
|
Calendar.getInstance(), MusicDirectoryChild(id = "12333")
|
|
|
|
)
|
2017-11-18 21:34:03 +01:00
|
|
|
|
|
|
|
val domainEntity = entity.toDomainEntity()
|
|
|
|
|
|
|
|
with(domainEntity) {
|
2018-03-24 19:30:03 +01:00
|
|
|
position `should be equal to` entity.position.toInt()
|
2021-05-07 15:36:11 +02:00
|
|
|
username `should be equal to` entity.username
|
|
|
|
comment `should be equal to` entity.comment
|
|
|
|
created `should be equal to` entity.created?.time
|
|
|
|
changed `should be equal to` entity.changed?.time
|
2021-12-21 12:16:40 +01:00
|
|
|
entry `should be equal to` entity.entry.toTrackEntity()
|
2017-11-18 21:34:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should convert list of entities to domain entities`() {
|
|
|
|
val entitiesList = listOf(Bookmark(443L), Bookmark(444L))
|
|
|
|
|
|
|
|
val domainEntitiesList = entitiesList.toDomainEntitiesList()
|
|
|
|
|
2018-03-24 19:30:03 +01:00
|
|
|
domainEntitiesList.size `should be equal to` entitiesList.size
|
2017-11-18 21:34:03 +01:00
|
|
|
domainEntitiesList.forEachIndexed({ index, bookmark ->
|
2021-05-07 15:36:11 +02:00
|
|
|
bookmark `should be equal to` entitiesList[index].toDomainEntity()
|
2017-11-18 21:34:03 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|