diff --git a/gabimoreno/src/main/java/soy/gabimoreno/data/remote/mapper/PodcastMapper.kt b/gabimoreno/src/main/java/soy/gabimoreno/data/remote/mapper/PodcastMapper.kt index 88b0ea9..4c081e6 100644 --- a/gabimoreno/src/main/java/soy/gabimoreno/data/remote/mapper/PodcastMapper.kt +++ b/gabimoreno/src/main/java/soy/gabimoreno/data/remote/mapper/PodcastMapper.kt @@ -64,9 +64,11 @@ private fun Article.getEpisodeUrl(): String { } private fun Article.getEpisodeCoverUrl(): String { - val episodeNumber = getEpisodeNumber() - if (episodeNumber == INVALID_EPISODE_NUMBER) return "" - return "$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX${getEpisodeNumber()}$PODCAST_COVER_SUFFIX" + return if (itunesArticleData?.image != null) { + this.itunesArticleData?.image!! + } else { + "" + } } private fun Article.getEpisodeNumber(): String { @@ -114,10 +116,6 @@ private const val HOURS_MINUTES_SECONDS_PATTERN = "HH:mm:ss" private const val ONE_MINUTE_IN_SECONDS = 60 private const val ONE_HOUR_IN_SECONDS = 60 * ONE_MINUTE_IN_SECONDS -@VisibleForTesting -internal const val PODCAST_COVER_PREFIX = - "images/podcast-los-androides/cover-podcast-los-androides-" - @VisibleForTesting internal const val PODCAST_COVER_SUFFIX = ".png" diff --git a/gabimoreno/src/test/java/soy/gabimoreno/data/remote/mapper/PodcastMapperKtTest.kt b/gabimoreno/src/test/java/soy/gabimoreno/data/remote/mapper/PodcastMapperKtTest.kt index d94de36..7de68a3 100644 --- a/gabimoreno/src/test/java/soy/gabimoreno/data/remote/mapper/PodcastMapperKtTest.kt +++ b/gabimoreno/src/test/java/soy/gabimoreno/data/remote/mapper/PodcastMapperKtTest.kt @@ -1,11 +1,16 @@ package soy.gabimoreno.data.remote.mapper -import com.prof.rssparser.* +import com.prof.rssparser.Article +import com.prof.rssparser.Channel +import com.prof.rssparser.Image +import com.prof.rssparser.ItunesArticleData +import com.prof.rssparser.ItunesChannelData +import com.prof.rssparser.ItunesOwner import org.amshove.kluent.shouldBe import org.amshove.kluent.shouldBeEqualTo import org.junit.Test import soy.gabimoreno.domain.model.GABI_MORENO_WEB_BASE_URL -import java.util.* +import java.util.Date class PodcastMapperKtTest { @@ -130,8 +135,7 @@ private const val EPISODE_ID = "guid" private const val EPISODE_NUMBER = "1234" private const val EPISODE_URL = "$GABI_MORENO_WEB_BASE_URL/$EPISODE_NUMBER" private const val EPISODE_AUDIO_URL = "audio" -private const val EPISODE_IMAGE_URL = - "$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX$EPISODE_NUMBER$PODCAST_COVER_SUFFIX" +private const val EPISODE_IMAGE_URL = "episodeImageUrl" private const val EPISODE_TITLE = "$EPISODE_NUMBER. Title" private const val EPISODE_AUDIO_LENGTH_IN_SECONDS = 896 private const val EPISODE_AUDIO_LENGTH_IN_TIME_FORMATTED = "01:51:15" diff --git a/gabimoreno/src/test/java/soy/gabimoreno/fake/FakeChannel.kt b/gabimoreno/src/test/java/soy/gabimoreno/fake/FakeChannel.kt index a7713c8..00d00fe 100644 --- a/gabimoreno/src/test/java/soy/gabimoreno/fake/FakeChannel.kt +++ b/gabimoreno/src/test/java/soy/gabimoreno/fake/FakeChannel.kt @@ -1,11 +1,13 @@ package soy.gabimoreno.fake -import com.prof.rssparser.* +import com.prof.rssparser.Article +import com.prof.rssparser.Channel +import com.prof.rssparser.Image +import com.prof.rssparser.ItunesArticleData +import com.prof.rssparser.ItunesChannelData +import com.prof.rssparser.ItunesOwner import soy.gabimoreno.data.remote.mapper.ANCHOR_MESSAGE import soy.gabimoreno.data.remote.mapper.IVOOX_URL -import soy.gabimoreno.data.remote.mapper.PODCAST_COVER_PREFIX -import soy.gabimoreno.data.remote.mapper.PODCAST_COVER_SUFFIX -import soy.gabimoreno.domain.model.GABI_MORENO_WEB_BASE_URL fun buildChannel(url: String): Channel { return Channel( @@ -83,8 +85,7 @@ private fun buildItunesArticleData(duration: String?) = ItunesArticleData( private const val EPISODE_ID = "guid" private const val EPISODE_NUMBER = "1234" private const val EPISODE_AUDIO_URL = "audio" -private const val EPISODE_IMAGE_URL = - "$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX$EPISODE_NUMBER$PODCAST_COVER_SUFFIX" +private const val EPISODE_IMAGE_URL = "episodeImageUrl" private const val EPISODE_TITLE = "$EPISODE_NUMBER. Title" private const val EPISODE_AUDIO_LENGTH_IN_SECONDS = 896 private const val EPISODE_AUDIO_LENGTH_IN_TIME_FORMATTED = "01:51:15"