Conversation
📝 WalkthroughWalkthroughThis PR converts three batch query methods for recently-blooming data from synchronous to asynchronous (suspend) functions across the Blooming domain layer. It removes caching infrastructure from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@pida-core/core-domain/src/test/kotlin/com/pida/blooming/BloomingServiceTest.kt`:
- Around line 45-124: Tests calling suspend methods recentlyBloomingBySpotIds,
recentlyBloomingByEventIds, and recentlyBloomingByCafeIds must run in a
coroutine test scope and use MockK's coroutine stubs/verifications: wrap each
test body in kotlinx.coroutines.test.runTest and replace every/verify with
coEvery/coVerify when stubbing/verifying
bloomingFinder.recentlyBloomingBySpotIds,
bloomingFinder.recentlyBloomingByEventIds, and
bloomingFinder.recentlyBloomingByCafeIds respectively so the suspend
interactions are executed and asserted correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2d41fac1-297e-4725-bb35-2e28d38b0934
📒 Files selected for processing (5)
pida-core/core-domain/src/main/kotlin/com/pida/blooming/BloomingFinder.ktpida-core/core-domain/src/main/kotlin/com/pida/blooming/BloomingRepository.ktpida-core/core-domain/src/main/kotlin/com/pida/blooming/BloomingService.ktpida-core/core-domain/src/test/kotlin/com/pida/blooming/BloomingServiceTest.ktpida-storage/db-core/src/main/kotlin/com/pida/storage/db/core/blooming/BloomingCoreRepository.kt
| @Test | ||
| fun `spot batch 조회는 중복 id를 제거한 뒤 한 번의 finder 호출로 위임한다`() { | ||
| val bloomingAppender = mockk<BloomingAppender>() | ||
| val bloomingValidator = mockk<BloomingValidator>() | ||
| val bloomingFinder = mockk<BloomingFinder>() | ||
| val service = BloomingService(bloomingAppender, bloomingValidator, bloomingFinder) | ||
| val bloomings = | ||
| listOf( | ||
| Blooming( | ||
| id = 1L, | ||
| status = BloomingStatus.BLOOMED, | ||
| userId = 10L, | ||
| flowerSpotId = 30L, | ||
| flowerEventId = null, | ||
| flowerSpotCafeId = null, | ||
| createdAt = LocalDateTime.of(2026, 4, 1, 9, 0), | ||
| ), | ||
| ) | ||
|
|
||
| every { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) } returns bloomings | ||
|
|
||
| val result = service.recentlyBloomingBySpotIds(listOf(30L, 31L, 30L)) | ||
|
|
||
| result shouldBe bloomings | ||
| verify(exactly = 1) { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `event batch 조회는 중복 id를 제거한 뒤 한 번의 finder 호출로 위임한다`() { | ||
| val bloomingAppender = mockk<BloomingAppender>() | ||
| val bloomingValidator = mockk<BloomingValidator>() | ||
| val bloomingFinder = mockk<BloomingFinder>() | ||
| val service = BloomingService(bloomingAppender, bloomingValidator, bloomingFinder) | ||
| val bloomings = | ||
| listOf( | ||
| Blooming( | ||
| id = 2L, | ||
| status = BloomingStatus.LITTLE, | ||
| userId = 11L, | ||
| flowerSpotId = null, | ||
| flowerEventId = 40L, | ||
| flowerSpotCafeId = null, | ||
| createdAt = LocalDateTime.of(2026, 4, 1, 10, 0), | ||
| ), | ||
| ) | ||
|
|
||
| every { bloomingFinder.recentlyBloomingByEventIds(listOf(40L, 41L)) } returns bloomings | ||
|
|
||
| val result = service.recentlyBloomingByEventIds(listOf(40L, 41L, 40L)) | ||
|
|
||
| result shouldBe bloomings | ||
| verify(exactly = 1) { bloomingFinder.recentlyBloomingByEventIds(listOf(40L, 41L)) } | ||
| } | ||
|
|
||
| @Test | ||
| fun `cafe batch 조회는 중복 id를 제거한 뒤 한 번의 finder 호출로 위임한다`() { | ||
| val bloomingAppender = mockk<BloomingAppender>() | ||
| val bloomingValidator = mockk<BloomingValidator>() | ||
| val bloomingFinder = mockk<BloomingFinder>() | ||
| val service = BloomingService(bloomingAppender, bloomingValidator, bloomingFinder) | ||
| val bloomings = | ||
| listOf( | ||
| Blooming( | ||
| id = 3L, | ||
| status = BloomingStatus.WITHERED, | ||
| userId = 12L, | ||
| flowerSpotId = null, | ||
| flowerEventId = null, | ||
| flowerSpotCafeId = 50L, | ||
| createdAt = LocalDateTime.of(2026, 4, 1, 11, 0), | ||
| ), | ||
| ) | ||
|
|
||
| every { bloomingFinder.recentlyBloomingByCafeIds(listOf(50L, 51L)) } returns bloomings | ||
|
|
||
| val result = service.recentlyBloomingByCafeIds(listOf(50L, 51L, 50L)) | ||
|
|
||
| result shouldBe bloomings | ||
| verify(exactly = 1) { bloomingFinder.recentlyBloomingByCafeIds(listOf(50L, 51L)) } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify coroutine-test usage and MockK coroutine DSL for new batch tests.
target="pida-core/core-domain/src/test/kotlin/com/pida/blooming/BloomingServiceTest.kt"
echo "[1] New batch tests declared without runTest:"
rg -nP 'fun `.*batch 조회.*`\(\)\s*\{' "$target"
echo "[2] Suspend finder stubs using every (should be coEvery):"
rg -nP 'every \{ bloomingFinder\.recentlyBloomingBy(Spot|Event|Cafe)Ids' "$target"
echo "[3] Suspend finder verifies using verify (should be coVerify):"
rg -nP 'verify\(exactly\s*=\s*1\)\s*\{ bloomingFinder\.recentlyBloomingBy(Spot|Event|Cafe)Ids' "$target"
echo "[4] Presence of coroutine-test constructs:"
rg -nP 'runTest|coEvery|coVerify' "$target"Repository: Team-PIDA/Pida-Server
Length of output: 1054
Suspend test calls need coroutine test scope and MockK coroutine DSL.
The three batch test functions (lines 46, 73, 100) invoke suspend service methods without wrapping in runTest. Additionally, suspend finder methods are stubbed and verified with every/verify instead of coEvery/coVerify.
🔧 Proposed fix pattern (apply to all three batch tests)
+import io.mockk.coEvery
+import io.mockk.coVerify
+import kotlinx.coroutines.test.runTest
@@
- fun `spot batch 조회는 중복 id를 제거한 뒤 한 번의 finder 호출로 위임한다`() {
+ fun `spot batch 조회는 중복 id를 제거한 뒤 한 번의 finder 호출로 위임한다`() = runTest {
@@
- every { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) } returns bloomings
+ coEvery { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) } returns bloomings
@@
- verify(exactly = 1) { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) }
+ coVerify(exactly = 1) { bloomingFinder.recentlyBloomingBySpotIds(listOf(30L, 31L)) }
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@pida-core/core-domain/src/test/kotlin/com/pida/blooming/BloomingServiceTest.kt`
around lines 45 - 124, Tests calling suspend methods recentlyBloomingBySpotIds,
recentlyBloomingByEventIds, and recentlyBloomingByCafeIds must run in a
coroutine test scope and use MockK's coroutine stubs/verifications: wrap each
test body in kotlinx.coroutines.test.runTest and replace every/verify with
coEvery/coVerify when stubbing/verifying
bloomingFinder.recentlyBloomingBySpotIds,
bloomingFinder.recentlyBloomingByEventIds, and
bloomingFinder.recentlyBloomingByCafeIds respectively so the suspend
interactions are executed and asserted correctly.
🌱 관련 이슈
📌 작업 내용 및 특이 사항
📝 참고
추후 개화 상태 테이블에 cafe와 event에 대한 데이터가 급증 시 해당 인덱스 추가할 계획
📌 체크 리스트
Summary by CodeRabbit
Refactor
Tests