2017-09-03 19:49:03 +02:00
|
|
|
@file:Suppress("IllegalIdentifier")
|
|
|
|
|
|
|
|
package org.moire.ultrasonic.data
|
|
|
|
|
|
|
|
import org.amshove.kluent.`should equal to`
|
|
|
|
import org.amshove.kluent.`should equal`
|
|
|
|
import org.junit.Test
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
|
|
|
|
|
|
|
|
/**
|
2017-12-16 20:51:07 +01:00
|
|
|
* Unit test for extension functions in APIPodcastConverter.kt file.
|
2017-09-03 19:49:03 +02:00
|
|
|
*/
|
|
|
|
class APIPodcastConverterTest {
|
|
|
|
@Test
|
|
|
|
fun `Should convert podcast channel entity to domain entity`() {
|
2017-12-16 20:51:07 +01:00
|
|
|
val entity = PodcastChannel(id = "452", url = "some-url", title = "some-title",
|
2017-09-03 19:49:03 +02:00
|
|
|
description = "some-description", coverArt = "cA", originalImageUrl = "image-url",
|
|
|
|
status = "podcast-status", errorMessage = "some-error-message")
|
|
|
|
|
|
|
|
val converterEntity = entity.toDomainEntity()
|
|
|
|
|
|
|
|
with(converterEntity) {
|
2017-12-16 20:51:07 +01:00
|
|
|
id = entity.id
|
2017-09-03 19:49:03 +02:00
|
|
|
description = entity.description
|
|
|
|
status = entity.status
|
|
|
|
title = entity.title
|
|
|
|
url = entity.url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun `Should convert list of podcasts channels to domain entites list`() {
|
|
|
|
val entitiesList = listOf(
|
2017-12-16 20:51:07 +01:00
|
|
|
PodcastChannel(id = "932", title = "title1"),
|
|
|
|
PodcastChannel(id = "12", title = "title2"))
|
2017-09-03 19:49:03 +02:00
|
|
|
|
|
|
|
val converted = entitiesList.toDomainEntitiesList()
|
|
|
|
|
|
|
|
with(converted) {
|
|
|
|
size `should equal to` entitiesList.size
|
|
|
|
this[0] `should equal` entitiesList[0].toDomainEntity()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|