diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/APILyricsConverter.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/APILyricsConverter.kt new file mode 100644 index 00000000..8571dc01 --- /dev/null +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/APILyricsConverter.kt @@ -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 +} diff --git a/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APILyricsConverterTest.kt b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APILyricsConverterTest.kt new file mode 100644 index 00000000..4ea41427 --- /dev/null +++ b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/data/APILyricsConverterTest.kt @@ -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 + } + } +}