diff --git a/data/src/main/java/com/gamss/android/data/remote/card/CardService.kt b/data/src/main/java/com/gamss/android/data/remote/card/CardService.kt index 3ba2006c..ee0a383a 100644 --- a/data/src/main/java/com/gamss/android/data/remote/card/CardService.kt +++ b/data/src/main/java/com/gamss/android/data/remote/card/CardService.kt @@ -1,6 +1,7 @@ package com.gamss.android.data.remote.card import com.gamss.android.data.remote.card.model.request.CreateCardRequest +import com.gamss.android.data.remote.card.model.response.CardCalendarResponse import com.gamss.android.data.remote.card.model.response.CardDeleteResponse import com.gamss.android.data.remote.card.model.response.CardResponse import com.gamss.android.data.remote.model.response.ApiResponse @@ -16,6 +17,12 @@ internal interface CardService { @GET("/api/cards") suspend fun getCardsByDate(@Query("date") date: String): ApiResponse> + /** 그 달(KST)의 날짜별 대표 감정 목록만 준다. */ + @GET("/api/cards/monthly") + suspend fun getCardsByMonth( + @Query("yearMonth") yearMonth: String, + ): ApiResponse> + /** 종료된 채팅방에만 만들 수 있다. 대사는 서버가 생성한다. */ @POST("/api/cards") suspend fun createCard(@Body request: CreateCardRequest): ApiResponse diff --git a/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardCalendarResponse.kt b/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardCalendarResponse.kt new file mode 100644 index 00000000..9d5a8f8b --- /dev/null +++ b/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardCalendarResponse.kt @@ -0,0 +1,20 @@ +package com.gamss.android.data.remote.card.model.response + +import com.gamss.android.data.remote.emotion.toEmotionCharacter +import com.gamss.android.domain.card.CardEntry +import kotlinx.serialization.Serializable + +@Serializable +internal data class CardCalendarResponse( + val date: String, + /** 카드 생성순이며 같은 감정이 여러 번 올 수 있다. */ + val emotions: List = emptyList(), +) + +internal fun CardCalendarResponse.toDomain(): List { + val createdDate = date.toLocalDateOrNull() ?: return emptyList() + return emotions.mapNotNull { it.toEmotionCharacter() } + .mapIndexed { index, character -> + CardEntry(date = createdDate, indexInDate = index, character = character) + } +} diff --git a/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardResponse.kt b/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardResponse.kt index f2e8e00f..8aedcb3c 100644 --- a/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardResponse.kt +++ b/data/src/main/java/com/gamss/android/data/remote/card/model/response/CardResponse.kt @@ -51,7 +51,8 @@ internal fun CardResponse.toDomainOrNull(): Card? = emotion.toEmotionCharacter() } } -private fun String.toLocalDateOrNull(): LocalDate? = try { +/** 날짜별·월별 응답이 같은 기준으로 날짜를 버려야 CardEntry.indexInDate 가 두 응답에서 같은 카드를 가리킨다. */ +internal fun String.toLocalDateOrNull(): LocalDate? = try { LocalDate.parse(this) } catch (_: DateTimeParseException) { null diff --git a/data/src/main/java/com/gamss/android/data/repository/CardRepositoryImpl.kt b/data/src/main/java/com/gamss/android/data/repository/CardRepositoryImpl.kt index 538bc463..7de3d146 100644 --- a/data/src/main/java/com/gamss/android/data/repository/CardRepositoryImpl.kt +++ b/data/src/main/java/com/gamss/android/data/repository/CardRepositoryImpl.kt @@ -9,10 +9,12 @@ import com.gamss.android.data.remote.emotion.toServerEmotionType import com.gamss.android.data.remote.runCatchingApiCall import com.gamss.android.data.remote.throwIfFailed import com.gamss.android.domain.card.Card +import com.gamss.android.domain.card.CardEntry import com.gamss.android.domain.card.CardNotRetryableException import com.gamss.android.domain.card.CardRepository import com.gamss.android.domain.emotion.EmotionCharacter import java.time.LocalDate +import java.time.YearMonth import javax.inject.Inject import javax.inject.Singleton @@ -27,6 +29,14 @@ internal class CardRepositoryImpl @Inject constructor( checkNotNull(response.data) { "No available card data" }.mapNotNull { it.toDomainOrNull() } } + // YearMonth.toString() 이 서버가 요구하는 yyyy-MM 그대로다. + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = runCatchingApiCall { + val response = cardService.getCardsByMonth(yearMonth.toString()) + response.throwIfFailed() + checkNotNull(response.data) { "No available card data" } + .flatMap { it.toDomain() } + } + override suspend fun createCard( conversationId: Long, character: EmotionCharacter, diff --git a/data/src/test/java/com/gamss/android/data/repository/CardRepositoryImplTest.kt b/data/src/test/java/com/gamss/android/data/repository/CardRepositoryImplTest.kt index f9aa35b5..08ea5509 100644 --- a/data/src/test/java/com/gamss/android/data/repository/CardRepositoryImplTest.kt +++ b/data/src/test/java/com/gamss/android/data/repository/CardRepositoryImplTest.kt @@ -3,17 +3,22 @@ package com.gamss.android.data.repository import com.gamss.android.core.common.AppResult import com.gamss.android.core.common.network.ApiException import com.gamss.android.data.remote.card.CardService +import com.gamss.android.data.remote.card.model.response.CardCalendarResponse import com.gamss.android.data.remote.card.model.response.CardDeleteResponse import com.gamss.android.data.remote.model.response.ApiError import com.gamss.android.data.remote.model.response.ApiResponse import com.gamss.android.domain.auth.SessionExpiredException +import com.gamss.android.domain.card.CardEntry import com.gamss.android.domain.emotion.EmotionCharacter import io.mockk.coEvery +import io.mockk.coVerify import io.mockk.mockk import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test +import java.time.LocalDate +import java.time.YearMonth class CardRepositoryImplTest { @@ -131,4 +136,63 @@ class CardRepositoryImplTest { ((result as AppResult.Failure).throwable as ApiException).code, ) } + + @Test + fun `월을 API 형식으로 조회하고 하루치 감정 목록을 카드 한 건씩으로 펼친다`() = runTest { + coEvery { cardService.getCardsByMonth("2026-08") } returns ApiResponse( + success = true, + data = listOf( + CardCalendarResponse(date = "2026-08-15", emotions = listOf("ANGER", "JOY")), + CardCalendarResponse(date = "2026-08-16", emotions = listOf("GRUMPY")), + ), + ) + + val result = repository.getCardsByMonth(YearMonth.of(2026, 8)) + + assertEquals( + listOf( + CardEntry(LocalDate.of(2026, 8, 15), 0, EmotionCharacter.ANGER), + CardEntry(LocalDate.of(2026, 8, 15), 1, EmotionCharacter.JOY), + CardEntry(LocalDate.of(2026, 8, 16), 0, EmotionCharacter.PRICKLY), + ), + (result as AppResult.Success).data, + ) + coVerify(exactly = 1) { cardService.getCardsByMonth("2026-08") } + } + + /** 날짜별 조회도 알 수 없는 감정을 버리므로, 순번은 버린 뒤를 기준으로 세야 두 응답이 맞물린다. */ + @Test + fun `날짜를 못 읽는 날은 그 날만 버리고 나머지 달은 살린다`() = runTest { + coEvery { cardService.getCardsByMonth(any()) } returns ApiResponse( + success = true, + data = listOf( + CardCalendarResponse(date = "2026-08-99", emotions = listOf("ANGER")), + CardCalendarResponse(date = "2026-08-16", emotions = listOf("JOY")), + ), + ) + + val result = repository.getCardsByMonth(YearMonth.of(2026, 8)) + + assertEquals( + listOf(CardEntry(LocalDate.of(2026, 8, 16), 0, EmotionCharacter.JOY)), + (result as AppResult.Success).data, + ) + } + + @Test + fun `알 수 없는 감정을 버린 뒤를 기준으로 그날 순번을 센다`() = runTest { + coEvery { cardService.getCardsByMonth(any()) } returns ApiResponse( + success = true, + data = listOf( + CardCalendarResponse(date = "2026-08-15", emotions = listOf("UNKNOWN", "ANGER")), + ), + ) + + val result = repository.getCardsByMonth(YearMonth.of(2026, 8)) + + assertEquals( + listOf(CardEntry(LocalDate.of(2026, 8, 15), 0, EmotionCharacter.ANGER)), + (result as AppResult.Success).data, + ) + } } diff --git a/domain/src/main/kotlin/com/gamss/android/domain/card/CardEntry.kt b/domain/src/main/kotlin/com/gamss/android/domain/card/CardEntry.kt new file mode 100644 index 00000000..6a051947 --- /dev/null +++ b/domain/src/main/kotlin/com/gamss/android/domain/card/CardEntry.kt @@ -0,0 +1,11 @@ +package com.gamss.android.domain.card + +import com.gamss.android.domain.emotion.EmotionCharacter +import java.time.LocalDate + +/** 월별 응답에는 카드 식별자가 없어 [date] 와 그날 순번 [indexInDate] 가 카드의 신원이다. */ +data class CardEntry( + val date: LocalDate, + val indexInDate: Int, + val character: EmotionCharacter, +) diff --git a/domain/src/main/kotlin/com/gamss/android/domain/card/CardRepository.kt b/domain/src/main/kotlin/com/gamss/android/domain/card/CardRepository.kt index 62643bbe..423ac29d 100644 --- a/domain/src/main/kotlin/com/gamss/android/domain/card/CardRepository.kt +++ b/domain/src/main/kotlin/com/gamss/android/domain/card/CardRepository.kt @@ -3,12 +3,16 @@ package com.gamss.android.domain.card import com.gamss.android.core.common.AppResult import com.gamss.android.domain.emotion.EmotionCharacter import java.time.LocalDate +import java.time.YearMonth interface CardRepository { /** 대화 생성일(KST) 기준으로 해당 날짜의 카드를 가져온다. */ suspend fun getCardsByDate(date: LocalDate): AppResult> + /** 해당 달(KST)에 생성된 카드를 요약 없이 날짜·순번·감정만 가져온다. */ + suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> + /** 종료된 채팅방에만 만들 수 있고 방당 한 번만 성공한다. */ suspend fun createCard( conversationId: Long, diff --git a/domain/src/main/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCase.kt b/domain/src/main/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCase.kt new file mode 100644 index 00000000..ce28bfbd --- /dev/null +++ b/domain/src/main/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCase.kt @@ -0,0 +1,15 @@ +package com.gamss.android.domain.card + +import com.gamss.android.core.common.AppResult +import com.gamss.android.domain.usecase.UseCase +import java.time.YearMonth +import javax.inject.Inject + +/** 선택한 달(KST)에 생성된 카드를 요약 없이 조회한다. */ +class GetCardsByMonthUseCase @Inject constructor( + private val cardRepository: CardRepository, +) : UseCase>> { + + override suspend fun invoke(params: YearMonth): AppResult> = + cardRepository.getCardsByMonth(params) +} diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/CreateCardUseCaseTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/CreateCardUseCaseTest.kt index ec962ab9..5fd9e94e 100644 --- a/domain/src/test/kotlin/com/gamss/android/domain/card/CreateCardUseCaseTest.kt +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/CreateCardUseCaseTest.kt @@ -10,7 +10,7 @@ import java.time.LocalDate class CreateCardUseCaseTest { - private class RecordingRepository : CardRepository { + private class RecordingRepository : FakeCardRepository() { var sentSummary: String? = null private set @@ -32,16 +32,6 @@ class CreateCardUseCaseTest { ), ) } - - override suspend fun getCardsByDate(date: LocalDate): AppResult> = - AppResult.Success(emptyList()) - - override suspend fun deleteAllCards(): AppResult = error("사용하지 않음") - - override suspend fun deleteCard(cardId: Long): AppResult = error("사용하지 않음") - - override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult = - error("사용하지 않음") } @Test diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteAllCardsUseCaseTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteAllCardsUseCaseTest.kt index 77204e31..ccfb2bda 100644 --- a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteAllCardsUseCaseTest.kt +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteAllCardsUseCaseTest.kt @@ -1,34 +1,19 @@ package com.gamss.android.domain.card import com.gamss.android.core.common.AppResult -import com.gamss.android.domain.emotion.EmotionCharacter import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Test -import java.time.LocalDate class DeleteAllCardsUseCaseTest { - private class RecordingRepository : CardRepository { + private class RecordingRepository : FakeCardRepository() { var deleteAllCalled = false - override suspend fun getCardsByDate(date: LocalDate): AppResult> = error("사용하지 않음") - - override suspend fun createCard( - conversationId: Long, - character: EmotionCharacter, - summary: String, - ): AppResult = error("사용하지 않음") - override suspend fun deleteAllCards(): AppResult { deleteAllCalled = true return AppResult.Success(Unit) } - - override suspend fun deleteCard(cardId: Long): AppResult = error("사용하지 않음") - - override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult = - error("사용하지 않음") } @Test diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardUseCaseTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardUseCaseTest.kt index 7648b2f5..a673eaea 100644 --- a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardUseCaseTest.kt +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardUseCaseTest.kt @@ -1,35 +1,20 @@ package com.gamss.android.domain.card import com.gamss.android.core.common.AppResult -import com.gamss.android.domain.emotion.EmotionCharacter import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Test -import java.time.LocalDate class DeleteCardUseCaseTest { - private class RecordingRepository : CardRepository { + private class RecordingRepository : FakeCardRepository() { var deletedCardId: Long? = null private set - override suspend fun getCardsByDate(date: LocalDate): AppResult> = error("사용하지 않음") - - override suspend fun createCard( - conversationId: Long, - character: EmotionCharacter, - summary: String, - ): AppResult = error("사용하지 않음") - - override suspend fun deleteAllCards(): AppResult = error("사용하지 않음") - override suspend fun deleteCard(cardId: Long): AppResult { deletedCardId = cardId return AppResult.Success(Unit) } - - override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult = - error("사용하지 않음") } @Test diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardsByEmotionUseCaseTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardsByEmotionUseCaseTest.kt index 829ce288..06961023 100644 --- a/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardsByEmotionUseCaseTest.kt +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/DeleteCardsByEmotionUseCaseTest.kt @@ -5,25 +5,12 @@ import com.gamss.android.domain.emotion.EmotionCharacter import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Test -import java.time.LocalDate class DeleteCardsByEmotionUseCaseTest { - private class RecordingRepository : CardRepository { + private class RecordingRepository : FakeCardRepository() { var deletedCharacter: EmotionCharacter? = null - override suspend fun getCardsByDate(date: LocalDate): AppResult> = error("사용하지 않음") - - override suspend fun createCard( - conversationId: Long, - character: EmotionCharacter, - summary: String, - ): AppResult = error("사용하지 않음") - - override suspend fun deleteAllCards(): AppResult = error("사용하지 않음") - - override suspend fun deleteCard(cardId: Long): AppResult = error("사용하지 않음") - override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult { deletedCharacter = character return AppResult.Success(Unit) diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/FakeCardRepository.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/FakeCardRepository.kt new file mode 100644 index 00000000..d88e8c22 --- /dev/null +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/FakeCardRepository.kt @@ -0,0 +1,29 @@ +package com.gamss.android.domain.card + +import com.gamss.android.core.common.AppResult +import com.gamss.android.domain.emotion.EmotionCharacter +import java.time.LocalDate +import java.time.YearMonth + +/** 테스트가 실제로 쓰는 메서드만 override 한다. 나머지는 호출되면 바로 드러나야 한다. */ +internal open class FakeCardRepository : CardRepository { + + override suspend fun getCardsByDate(date: LocalDate): AppResult> = + error("이 테스트에서 쓰지 않는다") + + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = + error("이 테스트에서 쓰지 않는다") + + override suspend fun createCard( + conversationId: Long, + character: EmotionCharacter, + summary: String, + ): AppResult = error("이 테스트에서 쓰지 않는다") + + override suspend fun deleteAllCards(): AppResult = error("이 테스트에서 쓰지 않는다") + + override suspend fun deleteCard(cardId: Long): AppResult = error("이 테스트에서 쓰지 않는다") + + override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult = + error("이 테스트에서 쓰지 않는다") +} diff --git a/domain/src/test/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCaseTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCaseTest.kt new file mode 100644 index 00000000..fe52354b --- /dev/null +++ b/domain/src/test/kotlin/com/gamss/android/domain/card/GetCardsByMonthUseCaseTest.kt @@ -0,0 +1,39 @@ +package com.gamss.android.domain.card + +import com.gamss.android.core.common.AppResult +import com.gamss.android.domain.emotion.EmotionCharacter +import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertEquals +import org.junit.Assert.assertSame +import org.junit.Test +import java.time.LocalDate +import java.time.YearMonth + +class GetCardsByMonthUseCaseTest { + + @Test + fun `선택한 달을 그대로 저장소에 전달한다`() = runBlocking { + val yearMonth = YearMonth.of(2026, 8) + val expected = AppResult.Success( + listOf(CardEntry(LocalDate.of(2026, 8, 15), indexInDate = 0, character = EmotionCharacter.ANGER)), + ) + val repository = RecordingRepository(expected) + + val result = GetCardsByMonthUseCase(repository)(yearMonth) + + assertEquals(yearMonth, repository.requestedMonth) + assertSame(expected, result) + } + + private class RecordingRepository( + private val result: AppResult>, + ) : FakeCardRepository() { + var requestedMonth: YearMonth? = null + private set + + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> { + requestedMonth = yearMonth + return result + } + } +} diff --git a/domain/src/test/kotlin/com/gamss/android/domain/conversation/ConversationSessionTest.kt b/domain/src/test/kotlin/com/gamss/android/domain/conversation/ConversationSessionTest.kt index b2a48d3e..7b1a36b0 100644 --- a/domain/src/test/kotlin/com/gamss/android/domain/conversation/ConversationSessionTest.kt +++ b/domain/src/test/kotlin/com/gamss/android/domain/conversation/ConversationSessionTest.kt @@ -3,9 +3,9 @@ package com.gamss.android.domain.conversation import androidx.paging.PagingData import com.gamss.android.core.common.AppResult import com.gamss.android.domain.card.Card -import com.gamss.android.domain.card.CardRepository import com.gamss.android.domain.card.CreateCardUseCase import com.gamss.android.domain.card.CreateConversationCardUseCase +import com.gamss.android.domain.card.FakeCardRepository import com.gamss.android.domain.conversation.chattingsearch.ChattingRoomSummary import com.gamss.android.domain.emotion.ClassificationResult import com.gamss.android.domain.emotion.ConversationEmotionAccumulator @@ -288,10 +288,7 @@ class ConversationSessionTest { } } - private object NoOpCardRepository : CardRepository { - override suspend fun getCardsByDate(date: LocalDate): AppResult> = - AppResult.Success(emptyList()) - + private object NoOpCardRepository : FakeCardRepository() { override suspend fun createCard( conversationId: Long, character: EmotionCharacter, @@ -307,13 +304,6 @@ class ConversationSessionTest { date = LocalDate.of(2026, 8, 15), ), ) - - override suspend fun deleteAllCards(): AppResult = error("사용하지 않음") - - override suspend fun deleteCard(cardId: Long): AppResult = error("사용하지 않음") - - override suspend fun deleteCardsByEmotion(character: EmotionCharacter): AppResult = - error("사용하지 않음") } private class FakeConversationRepository( diff --git a/feature/calendar/src/test/java/com/gamss/android/feature/calendar/CalendarViewModelTest.kt b/feature/calendar/src/test/java/com/gamss/android/feature/calendar/CalendarViewModelTest.kt index cda16141..f5cdc0ac 100644 --- a/feature/calendar/src/test/java/com/gamss/android/feature/calendar/CalendarViewModelTest.kt +++ b/feature/calendar/src/test/java/com/gamss/android/feature/calendar/CalendarViewModelTest.kt @@ -2,6 +2,7 @@ package com.gamss.android.feature.calendar import com.gamss.android.core.common.AppResult import com.gamss.android.domain.card.Card +import com.gamss.android.domain.card.CardEntry import com.gamss.android.domain.card.CardRepository import com.gamss.android.domain.card.DeleteCardUseCase import com.gamss.android.domain.card.GetCardsByDateUseCase @@ -15,6 +16,7 @@ import org.junit.Assert.assertEquals import org.junit.Test import org.orbitmvi.orbit.test.test import java.time.LocalDate +import java.time.YearMonth @OptIn(ExperimentalCoroutinesApi::class) class CalendarViewModelTest { @@ -149,6 +151,9 @@ class CalendarViewModelTest { var deletedCardId: Long? = null private set + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = + error("캘린더 테스트에서 쓰지 않는다") + override suspend fun getCardsByDate(date: LocalDate): AppResult> { requestedDate = date requestCount++ @@ -186,6 +191,9 @@ class CalendarViewModelTest { private val firstRequestStarted = CompletableDeferred() private val secondRequestStarted = CompletableDeferred() + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = + error("캘린더 테스트에서 쓰지 않는다") + override suspend fun getCardsByDate(date: LocalDate): AppResult> { requestedDates += date when (requestedDates.size) { diff --git a/feature/chat/src/test/java/com/gamss/android/feature/chat/ChatRoomTestFakes.kt b/feature/chat/src/test/java/com/gamss/android/feature/chat/ChatRoomTestFakes.kt index 5d3cd2cc..e98b97cc 100644 --- a/feature/chat/src/test/java/com/gamss/android/feature/chat/ChatRoomTestFakes.kt +++ b/feature/chat/src/test/java/com/gamss/android/feature/chat/ChatRoomTestFakes.kt @@ -3,6 +3,7 @@ package com.gamss.android.feature.chat import androidx.paging.PagingData import com.gamss.android.core.common.AppResult import com.gamss.android.domain.card.Card +import com.gamss.android.domain.card.CardEntry import com.gamss.android.domain.card.CardRepository import com.gamss.android.domain.card.CreateCardUseCase import com.gamss.android.domain.card.CreateConversationCardUseCase @@ -41,6 +42,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.emptyFlow import java.time.LocalDate +import java.time.YearMonth /** * 채팅 ViewModel 조립을 한 곳에 둔다. 테스트마다 따로 조립하면 세션 구성이 갈라진다. @@ -210,6 +212,9 @@ internal class CountingCardRepository( var calls = 0 private set + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = + error("채팅 테스트에서 쓰지 않는다") + override suspend fun getCardsByDate(date: LocalDate): AppResult> = AppResult.Success(emptyList()) diff --git a/feature/home/src/test/java/com/gamss/android/feature/home/HomeTestFakes.kt b/feature/home/src/test/java/com/gamss/android/feature/home/HomeTestFakes.kt index 95ee133e..5af0a7d9 100644 --- a/feature/home/src/test/java/com/gamss/android/feature/home/HomeTestFakes.kt +++ b/feature/home/src/test/java/com/gamss/android/feature/home/HomeTestFakes.kt @@ -3,6 +3,7 @@ package com.gamss.android.feature.home import androidx.paging.PagingData import com.gamss.android.core.common.AppResult import com.gamss.android.domain.card.Card +import com.gamss.android.domain.card.CardEntry import com.gamss.android.domain.card.CardRepository import com.gamss.android.domain.card.CreateCardUseCase import com.gamss.android.domain.card.CreateConversationCardUseCase @@ -31,6 +32,7 @@ import com.gamss.android.domain.summary.UtteranceTokenCounter import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.flow.Flow import java.time.LocalDate +import java.time.YearMonth internal const val NEW_ROOM_ID = 42L @@ -120,6 +122,9 @@ internal class RecordingConversationRepository( } private object NoCardRepository : CardRepository { + override suspend fun getCardsByMonth(yearMonth: YearMonth): AppResult> = + error("홈 테스트에서 쓰지 않는다") + override suspend fun getCardsByDate(date: LocalDate): AppResult> = AppResult.Success(emptyList())