mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 19:50:35 +01:00
Add JukeboxStatus converter to domain entity.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
947a1ce3b5
commit
17aaa0f87f
@ -0,0 +1,13 @@
|
|||||||
|
// Collection of function to convert subsonic api jukebox responses to app entities
|
||||||
|
@file:JvmName("APIJukeboxConverter")
|
||||||
|
package org.moire.ultrasonic.data
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.domain.JukeboxStatus
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus as ApiJukeboxStatus
|
||||||
|
|
||||||
|
fun ApiJukeboxStatus.toDomainEntity(): JukeboxStatus = JukeboxStatus().apply {
|
||||||
|
positionSeconds = this@toDomainEntity.position
|
||||||
|
setCurrentIndex(this@toDomainEntity.currentIndex)
|
||||||
|
isPlaying = this@toDomainEntity.playing
|
||||||
|
gain = this@toDomainEntity.gain
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
@file:Suppress("IllegalIdentifier")
|
||||||
|
|
||||||
|
package org.moire.ultrasonic.data
|
||||||
|
|
||||||
|
import org.amshove.kluent.`should equal to`
|
||||||
|
import org.junit.Test
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for functions in [APIJukeboxConverter.kt] file.
|
||||||
|
*/
|
||||||
|
class APIJukeboxConverterTest {
|
||||||
|
@Test
|
||||||
|
fun `Should convert JukeboxStatus to domain entity`() {
|
||||||
|
val entity = JukeboxStatus(45, true, 0.11f, 442)
|
||||||
|
|
||||||
|
val convertedEntity = entity.toDomainEntity()
|
||||||
|
|
||||||
|
with(convertedEntity) {
|
||||||
|
currentPlayingIndex `should equal to` entity.currentIndex
|
||||||
|
gain `should equal to` entity.gain
|
||||||
|
isPlaying `should equal to` entity.playing
|
||||||
|
positionSeconds `should equal to` entity.position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user