From 8b5c872b45851d5398400d02848bc0b8f451b773 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 26 Jun 2026 02:48:02 +0900 Subject: [PATCH] =?UTF-8?q?feat(home-following):=20=EC=B5=9C=EA=B7=BC=20?= =?UTF-8?q?=EC=86=8C=EC=8B=9D=20source=20key=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/HomeFollowingNewsSourceKey.kt | 17 ++++++++++ .../domain/HomeFollowingNewsSourceKeyTest.kt | 33 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKey.kt create mode 100644 src/test/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKeyTest.kt diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKey.kt b/src/main/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKey.kt new file mode 100644 index 00000000..7aafec20 --- /dev/null +++ b/src/main/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKey.kt @@ -0,0 +1,17 @@ +package kr.co.vividnext.sodalive.v2.home.following.domain + +import java.time.LocalDateTime + +object HomeFollowingNewsSourceKey { + fun creatorRanking(creatorId: Long, aggregationStartAtUtc: LocalDateTime): String { + return "${FollowingNewsType.CREATOR_RANKING.name}:$creatorId:$aggregationStartAtUtc" + } + + fun audioContent(contentId: Long): String { + return "${FollowingNewsType.AUDIO_CONTENT.name}:$contentId" + } + + fun communityPost(postId: Long): String { + return "${FollowingNewsType.COMMUNITY_POST.name}:$postId" + } +} diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKeyTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKeyTest.kt new file mode 100644 index 00000000..af63ce48 --- /dev/null +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/home/following/domain/HomeFollowingNewsSourceKeyTest.kt @@ -0,0 +1,33 @@ +package kr.co.vividnext.sodalive.v2.home.following.domain + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import java.time.LocalDateTime + +class HomeFollowingNewsSourceKeyTest { + @Test + @DisplayName("크리에이터 랭킹 source key는 타입, 크리에이터, 집계 시작 시각으로 생성한다") + fun shouldCreateCreatorRankingSourceKey() { + val aggregationStartAtUtc = LocalDateTime.of(2026, 5, 31, 15, 0) + + val sourceKey = HomeFollowingNewsSourceKey.creatorRanking( + creatorId = 10L, + aggregationStartAtUtc = aggregationStartAtUtc + ) + + assertEquals("CREATOR_RANKING:10:2026-05-31T15:00", sourceKey) + } + + @Test + @DisplayName("오디오 콘텐츠 source key는 타입과 콘텐츠 id로 생성한다") + fun shouldCreateAudioContentSourceKey() { + assertEquals("AUDIO_CONTENT:300", HomeFollowingNewsSourceKey.audioContent(contentId = 300L)) + } + + @Test + @DisplayName("커뮤니티 게시글 source key는 타입과 게시글 id로 생성한다") + fun shouldCreateCommunityPostSourceKey() { + assertEquals("COMMUNITY_POST:400", HomeFollowingNewsSourceKey.communityPost(postId = 400L)) + } +}