Migrate to testFixtures, closes #451

pull/452/head
Simon Marquis 3 years ago
parent def11f26ff
commit f6b8259238

@ -44,4 +44,6 @@ dependencies {
implementation(libs.kotlinx.datetime) implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.serialization.json)
testImplementation(testFixtures(project(":core:model")))
} }

@ -16,10 +16,8 @@
package com.google.samples.apps.nowinandroid.core.database.model package com.google.samples.apps.nowinandroid.core.database.model
import com.google.samples.apps.nowinandroid.core.model.data.Author
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.datetime.Instant import kotlinx.datetime.Instant
import org.junit.Test import org.junit.Test
@ -58,39 +56,20 @@ class PopulatedNewsResourceKtTest {
) )
), ),
) )
val newsResource = populatedNewsResource.asExternalModel()
assertEquals( assertEquals(
NewsResource( NewsResource(
id = "1", id = populatedNewsResource.entity.id,
title = "news", title = populatedNewsResource.entity.title,
content = "Hilt", content = populatedNewsResource.entity.content,
url = "url", url = populatedNewsResource.entity.url,
headerImageUrl = "headerImageUrl", headerImageUrl = populatedNewsResource.entity.headerImageUrl,
type = Video, publishDate = populatedNewsResource.entity.publishDate,
publishDate = Instant.fromEpochMilliseconds(1), type = populatedNewsResource.entity.type,
authors = listOf( authors = populatedNewsResource.authors.map(AuthorEntity::asExternalModel),
Author( topics = populatedNewsResource.topics.map(TopicEntity::asExternalModel),
id = "2",
name = "name",
imageUrl = "imageUrl",
twitter = "twitter",
mediumPage = "mediumPage",
bio = "bio",
)
),
topics = listOf(
Topic(
id = "3",
name = "name",
shortDescription = "short description",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
)
), ),
newsResource populatedNewsResource.asExternalModel()
) )
} }
} }

@ -31,4 +31,6 @@ dependencies {
implementation(libs.hilt.android) implementation(libs.hilt.android)
kapt(libs.hilt.compiler) kapt(libs.hilt.compiler)
testImplementation(testFixtures(project(":core:model")))
} }

@ -18,10 +18,11 @@ package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NAME import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NAME
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
@ -87,7 +88,7 @@ class GetFollowableTopicsStreamUseCaseTest {
} }
private val testTopics = listOf( private val testTopics = listOf(
Topic("1", "Headlines", "", "", "", ""), Random.nextFakeTopic(id = "1", name = "Headlines"),
Topic("2", "Android Studio", "", "", "", ""), Random.nextFakeTopic(id = "2", name = "Android Studio"),
Topic("3", "Compose", "", "", "", ""), Random.nextFakeTopic(id = "3", name = "Compose"),
) )

@ -17,17 +17,16 @@
package com.google.samples.apps.nowinandroid.core.domain package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -125,81 +124,25 @@ class GetSaveableNewsResourcesStreamUseCaseTest {
} }
} }
private val sampleTopic1 = Topic( private val sampleTopic1 = Random.nextFakeTopic(id = "1", name = "Headlines")
id = "Topic1", private val sampleTopic2 = Random.nextFakeTopic(id = "2", name = "UI")
name = "Headlines", private val sampleAuthor1 = Random.nextFakeAuthor(id = "1")
shortDescription = "", private val sampleAuthor2 = Random.nextFakeAuthor(id = "2")
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
private val sampleTopic2 = Topic(
id = "Topic2",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
private val sampleAuthor1 =
Author(
id = "Author1",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
private val sampleAuthor2 =
Author(
id = "Author2",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(
NewsResource( Random.nextFakeNewsResource(
id = "1", id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers", authors = listOf(sampleAuthor1),
content = "Thank you everyone for following the Now in Android series and everything the " + topics = listOf(sampleTopic1)
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(sampleTopic1),
authors = listOf(sampleAuthor1)
), ),
NewsResource( Random.nextFakeNewsResource(
id = "2", id = "2",
title = "Transformations and customisations in the Paging Library", authors = listOf(sampleAuthor1),
content = "A demonstration of different operations that can be performed with Paging. " + topics = listOf(sampleTopic1, sampleTopic2)
"Transformations like inserting separators, when to create a new pager, and " +
"customisation options for consuming PagingData.",
url = "https://youtu.be/ZARz0pjm5YM",
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
type = Video,
topics = listOf(sampleTopic1, sampleTopic2),
authors = listOf(sampleAuthor1)
), ),
NewsResource( Random.nextFakeNewsResource(
id = "3", id = "3",
title = "Community tip on Paging", authors = listOf(sampleAuthor2),
content = "Tips for using the Paging library from the developer community", topics = listOf(sampleTopic2)
url = "https://youtu.be/r5JgIyS3t3s",
headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
type = Video,
topics = listOf(sampleTopic2),
authors = listOf(sampleAuthor2)
), ),
) )

@ -17,10 +17,11 @@
package com.google.samples.apps.nowinandroid.core.domain package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
@ -64,34 +65,8 @@ class GetSortedFollowableAuthorsStreamUseCaseTest {
} }
} }
private val sampleAuthor1 = private val sampleAuthor1 = Random.nextFakeAuthor(id = "1", name = "Mandy")
Author( private val sampleAuthor2 = Random.nextFakeAuthor(id = "2", name = "Andy")
id = "Author1", private val sampleAuthor3 = Random.nextFakeAuthor(id = "3", name = "Sandy")
name = "Mandy",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
private val sampleAuthor2 =
Author(
id = "Author2",
name = "Andy",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
private val sampleAuthor3 =
Author(
id = "Author2",
name = "Sandy",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
private val sampleAuthors = listOf(sampleAuthor1, sampleAuthor2, sampleAuthor3) private val sampleAuthors = listOf(sampleAuthor1, sampleAuthor2, sampleAuthor3)

@ -25,4 +25,6 @@ android {
dependencies { dependencies {
implementation(libs.kotlinx.datetime) implementation(libs.kotlinx.datetime)
androidTestImplementation(testFixtures(project(":core:model")))
testImplementation(testFixtures(project(":core:model")))
} }

@ -22,10 +22,9 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import kotlin.random.Random
import kotlinx.datetime.Instant
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -142,69 +141,12 @@ class AuthorScreenTest {
} }
} }
private const val AUTHOR_1_NAME = "Author 1"
private const val AUTHOR_2_NAME = "Author 2"
private const val AUTHOR_3_NAME = "Author 3"
private const val AUTHOR_BIO = "At vero eos et accusamus et iusto odio dignissimos ducimus qui."
private val testAuthors = listOf( private val testAuthors = listOf(
FollowableAuthor( FollowableAuthor(Random.nextFakeAuthor(id = "1"), isFollowed = true),
Author( FollowableAuthor(Random.nextFakeAuthor(id = "2"), isFollowed = false),
id = "0", FollowableAuthor(Random.nextFakeAuthor(id = "3"), isFollowed = false),
name = AUTHOR_1_NAME,
twitter = "",
bio = AUTHOR_BIO,
mediumPage = "",
imageUrl = ""
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = AUTHOR_2_NAME,
twitter = "",
bio = AUTHOR_BIO,
mediumPage = "",
imageUrl = ""
),
isFollowed = false
),
FollowableAuthor(
Author(
id = "2",
name = AUTHOR_3_NAME,
twitter = "",
bio = AUTHOR_BIO,
mediumPage = "",
imageUrl = ""
),
isFollowed = false
)
) )
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(
NewsResource( Random.nextFakeNewsResource(id = "1", authors = listOf(testAuthors.first().author)),
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and everything the " +
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
authors = listOf(
Author(
id = "0",
name = "Headlines",
twitter = "",
bio = AUTHOR_BIO,
mediumPage = "",
imageUrl = ""
)
),
topics = emptyList()
)
) )

@ -19,15 +19,15 @@ package com.google.samples.apps.nowinandroid.feature.author
import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.SavedStateHandle
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.testing.decoder.FakeStringDecoder import com.google.samples.apps.nowinandroid.core.testing.decoder.FakeStringDecoder
import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.feature.author.navigation.authorIdArg import com.google.samples.apps.nowinandroid.feature.author.navigation.authorIdArg
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertIs import kotlin.test.assertIs
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -37,7 +37,6 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -208,108 +207,18 @@ class AuthorViewModelTest {
} }
} }
private const val AUTHOR_1_NAME = "Author 1"
private const val AUTHOR_2_NAME = "Author 2"
private const val AUTHOR_3_NAME = "Author 3"
private const val AUTHOR_BIO = "At vero eos et accusamus."
private const val AUTHOR_TWITTER = "dev"
private const val AUTHOR_MEDIUM_PAGE = "URL"
private const val AUTHOR_IMAGE_URL = "Image URL"
private val testInputAuthors = listOf( private val testInputAuthors = listOf(
FollowableAuthor( FollowableAuthor(Random.nextFakeAuthor(id = "1"), isFollowed = true),
Author( FollowableAuthor(Random.nextFakeAuthor(id = "2"), isFollowed = false),
id = "0", FollowableAuthor(Random.nextFakeAuthor(id = "3"), isFollowed = false),
name = AUTHOR_1_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = AUTHOR_2_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = false
),
FollowableAuthor(
Author(
id = "2",
name = AUTHOR_3_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = false
)
) )
private val testOutputAuthors = listOf( private val testOutputAuthors = listOf(
FollowableAuthor( FollowableAuthor(testInputAuthors[0].author, isFollowed = true),
Author( FollowableAuthor(testInputAuthors[1].author, isFollowed = true),
id = "0", FollowableAuthor(testInputAuthors[2].author, isFollowed = false),
name = AUTHOR_1_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = AUTHOR_2_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "2",
name = AUTHOR_3_NAME,
bio = AUTHOR_BIO,
twitter = AUTHOR_TWITTER,
mediumPage = AUTHOR_MEDIUM_PAGE,
imageUrl = AUTHOR_IMAGE_URL,
),
isFollowed = false
)
) )
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(
NewsResource( Random.nextFakeNewsResource(id = "1", authors = listOf(testInputAuthors[0].author)),
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and everything the " +
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
authors = listOf(
Author(
id = "0",
name = "Android Dev",
bio = "Hello there!",
twitter = "dev",
mediumPage = "URL",
imageUrl = "image URL",
)
),
topics = emptyList()
)
) )

@ -27,4 +27,6 @@ dependencies {
implementation(libs.kotlinx.datetime) implementation(libs.kotlinx.datetime)
implementation(libs.accompanist.flowlayout) implementation(libs.accompanist.flowlayout)
androidTestImplementation(testFixtures(project(":core:model")))
testImplementation(testFixtures(project(":core:model")))
} }

@ -31,10 +31,11 @@ import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import kotlin.random.Random
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -341,43 +342,13 @@ class ForYouScreenTest {
} }
} }
private val testTopic = Topic( private val testAuthor = Random.nextFakeAuthor()
id = "",
name = "",
shortDescription = "",
longDescription = "",
url = "",
imageUrl = ""
)
private val testAuthor = Author(
id = "",
name = "",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = ""
)
private val testTopics = listOf( private val testTopics = listOf(
FollowableTopic( FollowableTopic(topic = Random.nextFakeTopic(id = "1", name = "Headlines"), isFollowed = false),
topic = testTopic.copy(id = "0", name = "Headlines"), FollowableTopic(topic = Random.nextFakeTopic(id = "2", name = "UI"), isFollowed = false),
isFollowed = false FollowableTopic(topic = Random.nextFakeTopic(id = "3", name = "Tools"), isFollowed = false),
),
FollowableTopic(
topic = testTopic.copy(id = "1", name = "UI"),
isFollowed = false
),
FollowableTopic(
topic = testTopic.copy(id = "2", name = "Tools"),
isFollowed = false
),
) )
private val testAuthors = listOf( private val testAuthors = listOf(
FollowableAuthor( FollowableAuthor(author = testAuthor.copy(id = "1", name = "Android Dev"), isFollowed = false),
author = testAuthor.copy(id = "0", name = "Android Dev"), FollowableAuthor(author = testAuthor.copy(id = "2", name = "Android Dev 2"), isFollowed = false)
isFollowed = false
),
FollowableAuthor(
author = testAuthor.copy(id = "1", name = "Android Dev 2"),
isFollowed = false
),
) )

@ -22,10 +22,9 @@ import com.google.samples.apps.nowinandroid.core.domain.GetSortedFollowableAutho
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository
@ -34,13 +33,13 @@ import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.core.testing.util.TestNetworkMonitor import com.google.samples.apps.nowinandroid.core.testing.util.TestNetworkMonitor
import com.google.samples.apps.nowinandroid.core.testing.util.TestSyncStatusMonitor import com.google.samples.apps.nowinandroid.core.testing.util.TestSyncStatusMonitor
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -193,83 +192,13 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList()
),
viewModel.feedState.value viewModel.feedState.value
) )
@ -291,84 +220,13 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList()
),
viewModel.feedState.value viewModel.feedState.value
) )
@ -385,7 +243,7 @@ class ForYouViewModelTest {
authorsRepository.sendAuthors(sampleAuthors) authorsRepository.sendAuthors(sampleAuthors)
userDataRepository.setFollowedAuthorIds(emptySet()) userDataRepository.setFollowedAuthorIds(emptySet())
topicsRepository.sendTopics(sampleTopics) topicsRepository.sendTopics(sampleTopics)
userDataRepository.setFollowedTopicIds(setOf("0", "1")) userDataRepository.setFollowedTopicIds(sampleTopics.take(2).map { it.id }.toSet())
viewModel.dismissOnboarding() viewModel.dismissOnboarding()
assertEquals( assertEquals(
@ -402,13 +260,7 @@ class ForYouViewModelTest {
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = feed = sampleNewsResources.map { SaveableNewsResource(it, isSaved = false) }
sampleNewsResources.map {
SaveableNewsResource(
newsResource = it,
isSaved = false
)
}
), ),
viewModel.feedState.value viewModel.feedState.value
) )
@ -431,174 +283,34 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList(),
),
viewModel.feedState.value viewModel.feedState.value
) )
viewModel.updateTopicSelection("1", isChecked = true) viewModel.updateTopicSelection(sampleTopics[1].id, isChecked = true)
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(sampleTopics[0], isFollowed = false),
topic = Topic( FollowableTopic(sampleTopics[1], isFollowed = true),
id = "0", FollowableTopic(sampleTopics[2], isFollowed = false),
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = true
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
), ),
authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(sampleNewsResources[1], isSaved = false),
newsResource = sampleNewsResources[1], SaveableNewsResource(sampleNewsResources[2], isSaved = false)
isSaved = false
),
SaveableNewsResource(
newsResource = sampleNewsResources[2],
isSaved = false
)
) )
), ),
viewModel.feedState.value viewModel.feedState.value
@ -622,159 +334,25 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList(),
),
viewModel.feedState.value viewModel.feedState.value
) )
viewModel.updateAuthorSelection("1", isChecked = true) viewModel.updateAuthorSelection(sampleAuthors[1].id, isChecked = true)
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic(
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf( authors = listOf(
FollowableAuthor( FollowableAuthor(sampleAuthors[0], isFollowed = false),
author = Author( FollowableAuthor(sampleAuthors[1], isFollowed = true),
id = "0", FollowableAuthor(sampleAuthors[2], isFollowed = false)
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = true
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
), ),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
@ -782,14 +360,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(sampleNewsResources[1], isSaved = false),
newsResource = sampleNewsResources[1], SaveableNewsResource(sampleNewsResources[2], isSaved = false)
isSaved = false
),
SaveableNewsResource(
newsResource = sampleNewsResources[2],
isSaved = false
)
) )
), ),
viewModel.feedState.value viewModel.feedState.value
@ -810,89 +382,19 @@ class ForYouViewModelTest {
authorsRepository.sendAuthors(sampleAuthors) authorsRepository.sendAuthors(sampleAuthors)
userDataRepository.setFollowedAuthorIds(emptySet()) userDataRepository.setFollowedAuthorIds(emptySet())
newsRepository.sendNewsResources(sampleNewsResources) newsRepository.sendNewsResources(sampleNewsResources)
viewModel.updateTopicSelection("1", isChecked = true) viewModel.updateTopicSelection(sampleTopics[1].id, isChecked = true)
viewModel.updateTopicSelection("1", isChecked = false) viewModel.updateTopicSelection(sampleTopics[1].id, isChecked = false)
advanceUntilIdle() advanceUntilIdle()
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList()
),
viewModel.feedState.value viewModel.feedState.value
) )
@ -911,89 +413,18 @@ class ForYouViewModelTest {
authorsRepository.sendAuthors(sampleAuthors) authorsRepository.sendAuthors(sampleAuthors)
userDataRepository.setFollowedAuthorIds(emptySet()) userDataRepository.setFollowedAuthorIds(emptySet())
newsRepository.sendNewsResources(sampleNewsResources) newsRepository.sendNewsResources(sampleNewsResources)
viewModel.updateAuthorSelection("1", isChecked = true) viewModel.updateAuthorSelection(sampleAuthors[1].id, isChecked = true)
viewModel.updateAuthorSelection("1", isChecked = false) viewModel.updateAuthorSelection(sampleAuthors[1].id, isChecked = false)
assertEquals( assertEquals(
OnboardingUiState.Shown( OnboardingUiState.Shown(
topics = listOf( topics = sampleTopics.map { FollowableTopic(it, isFollowed = false) },
FollowableTopic( authors = sampleAuthors.map { FollowableAuthor(it, isFollowed = false) },
topic = Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
),
FollowableTopic(
topic = Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
isFollowed = false
)
),
authors = listOf(
FollowableAuthor(
author = Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
author = Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
),
), ),
viewModel.onboardingUiState.value viewModel.onboardingUiState.value
) )
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(emptyList()),
feed = emptyList()
),
viewModel.feedState.value viewModel.feedState.value
) )
@ -1008,12 +439,12 @@ class ForYouViewModelTest {
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() } val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
topicsRepository.sendTopics(sampleTopics) topicsRepository.sendTopics(sampleTopics)
userDataRepository.setFollowedTopicIds(setOf("1")) userDataRepository.setFollowedTopicIds(setOf(sampleTopics[1].id))
authorsRepository.sendAuthors(sampleAuthors) authorsRepository.sendAuthors(sampleAuthors)
userDataRepository.setFollowedAuthorIds(setOf("1")) userDataRepository.setFollowedAuthorIds(setOf(sampleAuthors[1].id))
userDataRepository.setShouldHideOnboarding(true) userDataRepository.setShouldHideOnboarding(true)
newsRepository.sendNewsResources(sampleNewsResources) newsRepository.sendNewsResources(sampleNewsResources)
viewModel.updateNewsResourceSaved("2", true) viewModel.updateNewsResourceSaved(sampleNewsResources[1].id, true)
assertEquals( assertEquals(
OnboardingUiState.NotShown, OnboardingUiState.NotShown,
@ -1022,14 +453,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(sampleNewsResources[1], isSaved = true),
newsResource = sampleNewsResources[1], SaveableNewsResource(sampleNewsResources[2], isSaved = false)
isSaved = true
),
SaveableNewsResource(
newsResource = sampleNewsResources[2],
isSaved = false
)
) )
), ),
viewModel.feedState.value viewModel.feedState.value
@ -1041,150 +466,31 @@ class ForYouViewModelTest {
} }
private val sampleAuthors = listOf( private val sampleAuthors = listOf(
Author( Random.nextFakeAuthor(id = "1"),
id = "0", Random.nextFakeAuthor(id = "2"),
name = "Android Dev", Random.nextFakeAuthor(id = "3"),
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
) )
private val sampleTopics = listOf( private val sampleTopics = listOf(
Topic( Random.nextFakeTopic(id = "1", name = "Headlines"),
id = "0", Random.nextFakeTopic(id = "2", name = "UI"),
name = "Headlines", Random.nextFakeTopic(id = "3", name = "Tools"),
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
Topic(
id = "2",
name = "Tools",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
) )
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(
NewsResource( Random.nextFakeNewsResource(
id = "1", id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers", authors = listOf(sampleAuthors[0]),
content = "Thank you everyone for following the Now in Android series and everything the " + topics = listOf(sampleTopics[0])
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
), ),
authors = listOf( Random.nextFakeNewsResource(
Author(
id = "0",
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
)
),
NewsResource(
id = "2", id = "2",
title = "Transformations and customisations in the Paging Library", authors = listOf(sampleAuthors[1]),
content = "A demonstration of different operations that can be performed with Paging. " + topics = listOf(sampleTopics[1])
"Transformations like inserting separators, when to create a new pager, and " +
"customisation options for consuming PagingData.",
url = "https://youtu.be/ZARz0pjm5YM",
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
), ),
authors = listOf( Random.nextFakeNewsResource(
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
)
),
NewsResource(
id = "3", id = "3",
title = "Community tip on Paging", authors = listOf(sampleAuthors[1]),
content = "Tips for using the Paging library from the developer community", topics = listOf(sampleTopics[1])
url = "https://youtu.be/r5JgIyS3t3s",
headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
),
),
authors = listOf(
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
)
)
), ),
) )

@ -21,3 +21,7 @@ plugins {
android { android {
namespace = "com.google.samples.apps.nowinandroid.feature.interests" namespace = "com.google.samples.apps.nowinandroid.feature.interests"
} }
dependencies {
androidTestImplementation(testFixtures(project(":core:model")))
testImplementation(testFixtures(project(":core:model")))
}

@ -27,12 +27,13 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.feature.interests.InterestsScreen import com.google.samples.apps.nowinandroid.feature.interests.InterestsScreen
import com.google.samples.apps.nowinandroid.feature.interests.InterestsTabState import com.google.samples.apps.nowinandroid.feature.interests.InterestsTabState
import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
import com.google.samples.apps.nowinandroid.feature.interests.R import com.google.samples.apps.nowinandroid.feature.interests.R
import kotlin.random.Random
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -96,13 +97,13 @@ class InterestsScreenTest {
} }
composeTestRule composeTestRule
.onNodeWithText(TOPIC_1_NAME) .onNodeWithText(testTopics[0].topic.name)
.assertIsDisplayed() .assertIsDisplayed()
composeTestRule composeTestRule
.onNodeWithText(TOPIC_2_NAME) .onNodeWithText(testTopics[1].topic.name)
.assertIsDisplayed() .assertIsDisplayed()
composeTestRule composeTestRule
.onNodeWithText(TOPIC_3_NAME) .onNodeWithText(testTopics[2].topic.name)
.assertIsDisplayed() .assertIsDisplayed()
composeTestRule composeTestRule
@ -184,85 +185,26 @@ class InterestsScreenTest {
) )
} }
} }
private const val TOPIC_1_NAME = "Headlines"
private const val TOPIC_2_NAME = "UI"
private const val TOPIC_3_NAME = "Tools"
private const val TOPIC_SHORT_DESC = "At vero eos et accusamus." private const val TOPIC_SHORT_DESC = "At vero eos et accusamus."
private const val TOPIC_LONG_DESC = "At vero eos et accusamus et iusto odio dignissimos ducimus."
private const val TOPIC_URL = "URL"
private const val TOPIC_IMAGE_URL = "Image URL"
private val testTopics = listOf( private val testTopics = listOf(
FollowableTopic( FollowableTopic(
Topic( Random.nextFakeTopic(id = "1", shortDescription = TOPIC_SHORT_DESC),
id = "0",
name = TOPIC_1_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true isFollowed = true
), ),
FollowableTopic( FollowableTopic(
Topic( Random.nextFakeTopic(id = "2", shortDescription = TOPIC_SHORT_DESC),
id = "1",
name = TOPIC_2_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false isFollowed = false
), ),
FollowableTopic( FollowableTopic(
Topic( Random.nextFakeTopic(id = "3", shortDescription = TOPIC_SHORT_DESC),
id = "2",
name = TOPIC_3_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false isFollowed = false
) )
) )
private val testAuthors = listOf( private val testAuthors = listOf(
FollowableAuthor( FollowableAuthor(Random.nextFakeAuthor(id = "1", name = "Android Dev"), isFollowed = true),
Author( FollowableAuthor(Random.nextFakeAuthor(id = "2", name = "Android Dev 2"), isFollowed = false),
id = "0", FollowableAuthor(Random.nextFakeAuthor(id = "3", name = "Android Dev 3"), isFollowed = false),
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
) )
private val numberOfUnfollowedTopics = testTopics.filter { !it.isFollowed }.size private val numberOfUnfollowedTopics = testTopics.filter { !it.isFollowed }.size

@ -20,14 +20,15 @@ import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsStrea
import com.google.samples.apps.nowinandroid.core.domain.GetSortedFollowableAuthorsStreamUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSortedFollowableAuthorsStreamUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.model.data.nextFakeAuthor
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestAuthorsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
import com.google.samples.apps.nowinandroid.feature.interests.InterestsViewModel import com.google.samples.apps.nowinandroid.feature.interests.InterestsViewModel
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -204,154 +205,26 @@ class InterestsViewModelTest {
} }
} }
private const val TOPIC_1_NAME = "Android Studio"
private const val TOPIC_2_NAME = "Build"
private const val TOPIC_3_NAME = "Compose"
private const val TOPIC_SHORT_DESC = "At vero eos et accusamus."
private const val TOPIC_LONG_DESC = "At vero eos et accusamus et iusto odio dignissimos ducimus."
private const val TOPIC_URL = "URL"
private const val TOPIC_IMAGE_URL = "Image URL"
private val testInputAuthors = listOf( private val testInputAuthors = listOf(
FollowableAuthor( FollowableAuthor(author = Random.nextFakeAuthor(id = "1"), isFollowed = true),
Author( FollowableAuthor(author = Random.nextFakeAuthor(id = "2"), isFollowed = false),
id = "0", FollowableAuthor(author = Random.nextFakeAuthor(id = "3"), isFollowed = false),
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
),
FollowableAuthor(
Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
) )
private val testOutputAuthors = listOf( private val testOutputAuthors = listOf(
FollowableAuthor( FollowableAuthor(author = Random.nextFakeAuthor(id = "1"), isFollowed = true),
Author( FollowableAuthor(author = Random.nextFakeAuthor(id = "2"), isFollowed = true),
id = "0", FollowableAuthor(author = Random.nextFakeAuthor(id = "3"), isFollowed = false),
name = "Android Dev",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "1",
name = "Android Dev 2",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = true
),
FollowableAuthor(
Author(
id = "2",
name = "Android Dev 3",
imageUrl = "",
twitter = "",
mediumPage = "",
bio = "",
),
isFollowed = false
)
) )
private val testInputTopics = listOf( private val testInputTopics = listOf(
FollowableTopic( FollowableTopic(Random.nextFakeTopic(id = "1"), isFollowed = true),
Topic( FollowableTopic(Random.nextFakeTopic(id = "2"), isFollowed = false),
id = "0", FollowableTopic(Random.nextFakeTopic(id = "3"), isFollowed = false),
name = TOPIC_1_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "1",
name = TOPIC_2_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
),
FollowableTopic(
Topic(
id = "2",
name = TOPIC_3_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
)
) )
private val testOutputTopics = listOf( private val testOutputTopics = listOf(
FollowableTopic( FollowableTopic(Random.nextFakeTopic(id = "1"), isFollowed = true),
Topic( FollowableTopic(Random.nextFakeTopic(id = "2"), isFollowed = true),
id = "0", FollowableTopic(Random.nextFakeTopic(id = "3"), isFollowed = false),
name = TOPIC_1_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "1",
name = TOPIC_2_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "2",
name = TOPIC_3_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
)
) )

@ -25,4 +25,6 @@ android {
dependencies { dependencies {
implementation(libs.kotlinx.datetime) implementation(libs.kotlinx.datetime)
androidTestImplementation(testFixtures(project(":core:model")))
testImplementation(testFixtures(project(":core:model")))
} }

@ -26,10 +26,9 @@ import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic import kotlin.random.Random
import kotlinx.datetime.Instant
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -147,69 +146,10 @@ class TopicScreenTest {
} }
} }
private const val TOPIC_1_NAME = "Headlines"
private const val TOPIC_2_NAME = "UI"
private const val TOPIC_3_NAME = "Tools"
private const val TOPIC_DESC = "At vero eos et accusamus et iusto odio dignissimos ducimus qui."
private val testTopics = listOf( private val testTopics = listOf(
FollowableTopic( FollowableTopic(Random.nextFakeTopic(id = "1", name = "Headlines"), isFollowed = true),
Topic( FollowableTopic(Random.nextFakeTopic(id = "2", name = "UI"), isFollowed = false),
id = "0", FollowableTopic(Random.nextFakeTopic(id = "3", name = "Tools"), isFollowed = false),
name = TOPIC_1_NAME,
shortDescription = "",
longDescription = TOPIC_DESC,
url = "",
imageUrl = ""
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "1",
name = TOPIC_2_NAME,
shortDescription = "",
longDescription = TOPIC_DESC,
url = "",
imageUrl = ""
),
isFollowed = false
),
FollowableTopic(
Topic(
id = "2",
name = TOPIC_3_NAME,
shortDescription = "",
longDescription = TOPIC_DESC,
url = "",
imageUrl = ""
),
isFollowed = false
)
) )
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(Random.nextFakeNewsResource())
NewsResource(
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and everything the " +
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = TOPIC_DESC,
url = "",
imageUrl = ""
)
),
authors = emptyList()
)
)

@ -19,15 +19,15 @@ package com.google.samples.apps.nowinandroid.feature.topic
import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.SavedStateHandle
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.nextFakeNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.nextFakeTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.testing.decoder.FakeStringDecoder import com.google.samples.apps.nowinandroid.core.testing.decoder.FakeStringDecoder
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicIdArg import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicIdArg
import kotlin.random.Random
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertIs import kotlin.test.assertIs
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
@ -36,7 +36,6 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -165,108 +164,18 @@ class TopicViewModelTest {
} }
} }
private const val TOPIC_1_NAME = "Android Studio"
private const val TOPIC_2_NAME = "Build"
private const val TOPIC_3_NAME = "Compose"
private const val TOPIC_SHORT_DESC = "At vero eos et accusamus."
private const val TOPIC_LONG_DESC = "At vero eos et accusamus et iusto odio dignissimos ducimus."
private const val TOPIC_URL = "URL"
private const val TOPIC_IMAGE_URL = "Image URL"
private val testInputTopics = listOf( private val testInputTopics = listOf(
FollowableTopic( FollowableTopic(Random.nextFakeTopic(id = "1", name = "Android Studio"), isFollowed = true),
Topic( FollowableTopic(Random.nextFakeTopic(id = "2", name = "Build"), isFollowed = false),
id = "0", FollowableTopic(Random.nextFakeTopic(id = "3", name = "Compose"), isFollowed = false),
name = TOPIC_1_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "1",
name = TOPIC_2_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
),
FollowableTopic(
Topic(
id = "2",
name = TOPIC_3_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
)
) )
private val testOutputTopics = listOf( private val testOutputTopics = listOf(
FollowableTopic( testInputTopics[0],
Topic( testInputTopics[1].copy(isFollowed = true),
id = "0", testInputTopics[2],
name = TOPIC_1_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "1",
name = TOPIC_2_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = true
),
FollowableTopic(
Topic(
id = "2",
name = TOPIC_3_NAME,
shortDescription = TOPIC_SHORT_DESC,
longDescription = TOPIC_LONG_DESC,
url = TOPIC_URL,
imageUrl = TOPIC_IMAGE_URL,
),
isFollowed = false
)
) )
private val sampleNewsResources = listOf( private val sampleNewsResources = listOf(
NewsResource( Random.nextFakeNewsResource(id = "1", topics = listOf(testInputTopics[0].topic)),
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and everything the " +
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "long description",
url = "URL",
imageUrl = "image URL",
)
),
authors = emptyList()
)
) )

Loading…
Cancel
Save