feat(home): AI 캐릭터 빈 스냅샷 마커를 저장한다

This commit is contained in:
2026-07-10 03:21:16 +09:00
parent 2a0d2a385a
commit ca26577279
4 changed files with 68 additions and 0 deletions
@@ -108,6 +108,40 @@ class RecommendationSnapshotPersistenceAdapterTest @Autowired constructor(
assertEquals(3, repository.findAll().size)
}
@Test
fun shouldClearAiCharacterSectionSnapshotsWhenReplacingWithEmptySnapshots() {
val oldSnapshotAt = LocalDateTime.of(2026, 5, 28, 23, 59, 59)
val snapshotAt = LocalDateTime.of(2026, 5, 29, 23, 59, 59)
repository.saveAll(
listOf(
snapshot(RecommendedSectionType.AI_CHARACTER, targetId = 1L, score = 100.0, snapshotAt = oldSnapshotAt),
snapshot(RecommendedSectionType.CHEER_CREATOR, targetId = 2L, score = 200.0, snapshotAt = oldSnapshotAt)
)
)
adapter.replaceSnapshots(RecommendedSectionType.AI_CHARACTER, snapshotAt, emptyList())
assertEquals(emptyList<RecommendationSnapshotRecord>(), adapter.findLatestSnapshots(RecommendedSectionType.AI_CHARACTER))
assertEquals(listOf(2L), adapter.findLatestSnapshots(RecommendedSectionType.CHEER_CREATOR).map { it.targetId })
assertEquals(true, adapter.existsLatestSnapshot(RecommendedSectionType.AI_CHARACTER))
assertEquals(
listOf(0L),
repository.findAll()
.filter { it.sectionType == RecommendedSectionType.AI_CHARACTER }
.map { it.targetId }
)
}
@Test
fun shouldExcludeEmptySnapshotMarkerFromLatestSnapshotResults() {
val snapshotAt = LocalDateTime.of(2026, 5, 29, 23, 59, 59)
adapter.replaceSnapshots(RecommendedSectionType.AI_CHARACTER, snapshotAt, emptyList())
assertEquals(emptyList<RecommendationSnapshotRecord>(), adapter.findLatestSnapshots(RecommendedSectionType.AI_CHARACTER))
assertEquals(true, adapter.existsLatestSnapshot(RecommendedSectionType.AI_CHARACTER))
}
private fun snapshot(
sectionType: RecommendedSectionType,
targetId: Long,