mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-08 07:48:53 +01:00
Add converting subsonic api Lyrics entity to domain entity.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
9844fb1282
commit
290eb95246
@ -0,0 +1,13 @@
|
|||||||
|
// Converts Lyrics entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
|
||||||
|
// to app domain entities.
|
||||||
|
@file:JvmName("APILyricsConverter")
|
||||||
|
package org.moire.ultrasonic.data
|
||||||
|
|
||||||
|
import org.moire.ultrasonic.domain.Lyrics
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.Lyrics as APILyrics
|
||||||
|
|
||||||
|
fun APILyrics.toDomainEntity(): Lyrics = Lyrics().apply {
|
||||||
|
artist = this@toDomainEntity.artist
|
||||||
|
title = this@toDomainEntity.title
|
||||||
|
text = this@toDomainEntity.text
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
@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.Lyrics
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for extension functions in [APILyricsConverter.kt] file.
|
||||||
|
*/
|
||||||
|
class APILyricsConverterTest {
|
||||||
|
@Test
|
||||||
|
fun `Should convert Lyrics entity to domain`() {
|
||||||
|
val entity = Lyrics(artist = "some-artist", title = "some-title", text = "song-text")
|
||||||
|
|
||||||
|
val convertedEntity = entity.toDomainEntity()
|
||||||
|
|
||||||
|
with(convertedEntity) {
|
||||||
|
artist `should equal to` entity.artist
|
||||||
|
title `should equal to` entity.title
|
||||||
|
text `should equal to` entity.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user