feat(creator-channel): 오디오 탭 조회 계약을 추가한다

This commit is contained in:
2026-06-19 15:17:18 +09:00
parent f3a574a54a
commit 9a1bfed6a4
3 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
package kr.co.vividnext.sodalive.v2.creator.channel.audio.application
import kr.co.vividnext.sodalive.member.MemberRole
import kr.co.vividnext.sodalive.v2.common.domain.ContentSort
import kr.co.vividnext.sodalive.v2.creator.channel.audio.domain.CreatorChannelAudioTab
import kr.co.vividnext.sodalive.v2.creator.channel.audio.domain.CreatorChannelAudioTheme
import kr.co.vividnext.sodalive.v2.creator.channel.audio.port.out.CreatorChannelAudioContentRecord
import kr.co.vividnext.sodalive.v2.creator.channel.audio.port.out.CreatorChannelAudioCreatorRecord
import kr.co.vividnext.sodalive.v2.creator.channel.audio.port.out.CreatorChannelAudioQueryPort
import kr.co.vividnext.sodalive.v2.creator.channel.audio.port.out.CreatorChannelAudioThemeRecord
import kr.co.vividnext.sodalive.v2.creator.channel.common.domain.CreatorChannelAudioContent
import kr.co.vividnext.sodalive.v2.creator.channel.live.domain.CreatorChannelPage
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.time.LocalDateTime
class CreatorChannelAudioQueryServiceTest {
@Test
@DisplayName("오디오 탭 domain model과 port 계약을 사용할 수 있다")
fun shouldUseAudioTabDomainModelAndPortContract() {
val page = CreatorChannelPage(page = 0, size = 20)
val tab = CreatorChannelAudioTab(
audioContentCount = 1,
paidAudioContentCount = 1,
purchasedAudioContentCount = 1,
purchasedAudioContentRate = 100.0,
themes = listOf(CreatorChannelAudioTheme(themeId = 10L, themeName = "theme")),
audioContents = listOf(audioContent()),
sort = ContentSort.LATEST,
themeId = 10L,
page = page,
hasNext = false
)
val port = FakeCreatorChannelAudioQueryPort()
assertEquals(1, tab.audioContentCount)
assertEquals(10L, tab.themes.first().themeId)
assertEquals(100L, tab.audioContents.first().audioContentId)
assertEquals(MemberRole.CREATOR, port.findCreator(creatorId = 1L, viewerId = 2L)?.role)
}
private fun audioContent(): CreatorChannelAudioContent {
return CreatorChannelAudioContent(
audioContentId = 100L,
title = "audio",
duration = "00:01:00",
imageUrl = null,
price = 10,
isAdult = false,
isPointAvailable = true,
isFirstContent = true,
seriesName = null,
isOriginalSeries = null,
isOwned = true,
isRented = false
)
}
private class FakeCreatorChannelAudioQueryPort : CreatorChannelAudioQueryPort {
override fun findCreator(creatorId: Long, viewerId: Long?): CreatorChannelAudioCreatorRecord? {
return CreatorChannelAudioCreatorRecord(
creatorId = creatorId,
role = MemberRole.CREATOR,
nickname = "creator"
)
}
override fun existsBlockedBetween(viewerId: Long, creatorId: Long): Boolean {
return false
}
override fun findActiveThemeId(themeId: Long): Long? {
return themeId
}
override fun findAudioThemes(locale: String): List<CreatorChannelAudioThemeRecord> {
return listOf(CreatorChannelAudioThemeRecord(themeId = 10L, themeName = locale))
}
override fun countAudioContents(
creatorId: Long,
themeId: Long?,
now: LocalDateTime,
canViewAdultContent: Boolean
): Int {
return 1
}
override fun countPaidAudioContents(
creatorId: Long,
themeId: Long?,
now: LocalDateTime,
canViewAdultContent: Boolean
): Int {
return 1
}
override fun countPurchasedAudioContents(
creatorId: Long,
viewerId: Long,
themeId: Long?,
now: LocalDateTime,
canViewAdultContent: Boolean
): Int {
return 1
}
override fun findAudioContents(
creatorId: Long,
viewerId: Long,
themeId: Long?,
now: LocalDateTime,
canViewAdultContent: Boolean,
sort: ContentSort,
locale: String,
offset: Long,
limit: Int
): List<CreatorChannelAudioContentRecord> {
return emptyList()
}
}
}