Convert :core:domain to the multiplatform module

pull/1323/head
lihenggui 2 years ago
parent 05567c6701
commit 7c0dd986e6

@ -14,7 +14,8 @@
* limitations under the License.
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.kmp.library)
alias(libs.plugins.nowinandroid.kotlin.inject)
alias(libs.plugins.nowinandroid.android.library.jacoco)
id("com.google.devtools.ksp")
}
@ -23,11 +24,14 @@ android {
namespace = "com.google.samples.apps.nowinandroid.core.domain"
}
dependencies {
api(projects.core.data)
api(projects.core.model)
implementation(libs.javax.inject)
testImplementation(projects.core.testing)
}
kotlin {
sourceSets {
commonMain.dependencies {
api(projects.core.data)
api(projects.core.model)
}
commonTest.dependencies {
implementation(projects.core.testing)
}
}
}

@ -23,12 +23,11 @@ import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NONE
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import javax.inject.Inject
/**
* A use case which obtains a list of topics with their followed state.
*/
class GetFollowableTopicsUseCase @Inject constructor(
class GetFollowableTopicsUseCase(
private val topicsRepository: TopicsRepository,
private val userDataRepository: UserDataRepository,
) {

@ -19,12 +19,13 @@ package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery
import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import me.tatarka.inject.annotations.Inject
/**
* A use case which returns the recent search queries.
*/
class GetRecentSearchQueriesUseCase @Inject constructor(
@Inject
class GetRecentSearchQueriesUseCase(
private val recentSearchRepository: RecentSearchRepository,
) {
operator fun invoke(limit: Int = 10): Flow<List<RecentSearchQuery>> =

@ -18,12 +18,13 @@ package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import me.tatarka.inject.annotations.Inject
/**
* A use case which returns total count of *Fts tables
*/
class GetSearchContentsCountUseCase @Inject constructor(
@Inject
class GetSearchContentsCountUseCase(
private val searchContentsRepository: SearchContentsRepository,
) {
operator fun invoke(): Flow<Int> =

@ -25,12 +25,13 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.UserSearchResult
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import javax.inject.Inject
import me.tatarka.inject.annotations.Inject
/**
* A use case which returns the searched contents matched with the search query.
*/
class GetSearchContentsUseCase @Inject constructor(
@Inject
class GetSearchContentsUseCase(
private val searchContentsRepository: SearchContentsRepository,
private val userDataRepository: UserDataRepository,
) {

@ -21,18 +21,13 @@ import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.Topic
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.util.MainDispatcherRule
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals
class GetFollowableTopicsUseCaseTest {
@get:Rule
val mainDispatcherRule = MainDispatcherRule()
private val topicsRepository = TestTopicsRepository()
private val userDataRepository = TestUserDataRepository()

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest />
Loading…
Cancel
Save