|
|
@ -20,6 +20,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Topic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Topic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.asExternalModel
|
|
|
|
import kotlinx.datetime.Instant
|
|
|
|
import kotlinx.datetime.Instant
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.Test
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
import kotlin.test.assertEquals
|
|
|
@ -69,6 +70,29 @@ class NetworkEntityTest {
|
|
|
|
assertEquals("Article 📚", entity.type)
|
|
|
|
assertEquals("Article 📚", entity.type)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun networkTopicMapsToExternalModel() {
|
|
|
|
|
|
|
|
val networkTopic = NetworkTopic(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Test",
|
|
|
|
|
|
|
|
shortDescription = "short description",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "imageUrl"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val expected = Topic(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Test",
|
|
|
|
|
|
|
|
shortDescription = "short description",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "imageUrl",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(expected, networkTopic.asExternalModel())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun networkNewsResourceMapsToExternalModel() {
|
|
|
|
fun networkNewsResourceMapsToExternalModel() {
|
|
|
|
val networkNewsResource = NetworkNewsResource(
|
|
|
|
val networkNewsResource = NetworkNewsResource(
|
|
|
@ -109,24 +133,7 @@ class NetworkEntityTest {
|
|
|
|
headerImageUrl = "headerImageUrl",
|
|
|
|
headerImageUrl = "headerImageUrl",
|
|
|
|
publishDate = Instant.fromEpochMilliseconds(1),
|
|
|
|
publishDate = Instant.fromEpochMilliseconds(1),
|
|
|
|
type = "Article 📚",
|
|
|
|
type = "Article 📚",
|
|
|
|
topics = listOf(
|
|
|
|
topics = networkTopics.map(NetworkTopic::asExternalModel),
|
|
|
|
Topic(
|
|
|
|
|
|
|
|
id = "1",
|
|
|
|
|
|
|
|
name = "Test 1",
|
|
|
|
|
|
|
|
shortDescription = "short description 1",
|
|
|
|
|
|
|
|
longDescription = "long description 1",
|
|
|
|
|
|
|
|
url = "url 1",
|
|
|
|
|
|
|
|
imageUrl = "imageUrl 1",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Topic(
|
|
|
|
|
|
|
|
id = "2",
|
|
|
|
|
|
|
|
name = "Test 2",
|
|
|
|
|
|
|
|
shortDescription = "short description 2",
|
|
|
|
|
|
|
|
longDescription = "long description 2",
|
|
|
|
|
|
|
|
url = "url 2",
|
|
|
|
|
|
|
|
imageUrl = "imageUrl 2",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(expected, networkNewsResource.asExternalModel(networkTopics))
|
|
|
|
assertEquals(expected, networkNewsResource.asExternalModel(networkTopics))
|
|
|
|
}
|
|
|
|
}
|
|
|
|